Skip to content

Commit

Permalink
ic3: off by one in mode_show()
Browse files Browse the repository at this point in the history
This should be >= ARRAY_SIZE() to avoid reading one element beyond the
end of the array.

Fixes: 3a379bb ("i3c: Add core I3C infrastructure")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Boris Brezillon <[email protected]>
  • Loading branch information
Dan Carpenter authored and Boris Brezillon committed Dec 5, 2018
1 parent 840414a commit afe120c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/i3c/master.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static ssize_t mode_show(struct device *dev,

i3c_bus_normaluse_lock(i3cbus);
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])
ret = sprintf(buf, "unknown\n");
else
Expand Down

0 comments on commit afe120c

Please sign in to comment.