Skip to content

Commit

Permalink
platform/chrome: cros_ec_sensorhub: Off by one in cros_sensorhub_send…
Browse files Browse the repository at this point in the history
…_sample()

The sensorhub->push_data[] array has sensorhub->sensor_num elements.
It's allocated in cros_ec_sensorhub_ring_add().  So the > should be >=
to prevent a read one element beyond the end of the array.

Fixes: 145d59b ("platform/chrome: cros_ec_sensorhub: Add FIFO support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
  • Loading branch information
Dan Carpenter authored and Enric Balletbo i Serra committed Apr 13, 2020
1 parent a463877 commit 5b69c23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/platform/chrome/cros_ec_sensorhub_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cros_sensorhub_send_sample(struct cros_ec_sensorhub *sensorhub,
int id = sample->sensor_id;
struct iio_dev *indio_dev;

if (id > sensorhub->sensor_num)
if (id >= sensorhub->sensor_num)
return -EINVAL;

cb = sensorhub->push_data[id].push_data_cb;
Expand Down

0 comments on commit 5b69c23

Please sign in to comment.