ic3: off by one in mode_show()

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

Fixes: 3a379bbcea ("i3c: Add core I3C infrastructure")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
This commit is contained in:
Dan Carpenter 2018-11-23 10:15:05 +03:00 committed by Boris Brezillon
parent 840414ae59
commit afe120c777

View file

@ -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