Commit afe120c7 authored by Dan Carpenter's avatar Dan Carpenter Committed by Boris Brezillon

ic3: off by one in mode_show()

This should be >= ARRAY_SIZE() to avoid reading one element beyond the
end of the array.

Fixes: 3a379bbc ("i3c: Add core I3C infrastructure")
Signed-off-by: default avatarDan Carpenter <>
Signed-off-by: default avatarBoris Brezillon <>
parent 840414ae
...@@ -475,7 +475,7 @@ static ssize_t mode_show(struct device *dev, ...@@ -475,7 +475,7 @@ static ssize_t mode_show(struct device *dev,
i3c_bus_normaluse_lock(i3cbus); i3c_bus_normaluse_lock(i3cbus);
if (i3cbus->mode < 0 || if (i3cbus->mode < 0 ||
i3cbus->mode > ARRAY_SIZE(i3c_bus_mode_strings) || i3cbus->mode >= ARRAY_SIZE(i3c_bus_mode_strings) ||
!i3c_bus_mode_strings[i3cbus->mode]) !i3c_bus_mode_strings[i3cbus->mode])
ret = sprintf(buf, "unknown\n"); ret = sprintf(buf, "unknown\n");
else else
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment