Skip to content

Commit 8a46290

Browse files
yiyuanerjic23
authored andcommitted
iio: cros_ec: Fix the allocation size for cros_ec_command
The struct cros_ec_command contains several integer fields and a trailing array. An allocation size neglecting the integer fields can lead to buffer overrun. Reviewed-by: Tzung-Bi Shih <[email protected]> Signed-off-by: Yiyuan Guo <[email protected]> Fixes: 974e6f0 ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.") Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 6811694 commit 8a46290

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
253253
platform_set_drvdata(pdev, indio_dev);
254254

255255
state->ec = ec->ec_dev;
256-
state->msg = devm_kzalloc(&pdev->dev,
256+
state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) +
257257
max((u16)sizeof(struct ec_params_motion_sense),
258258
state->ec->max_response), GFP_KERNEL);
259259
if (!state->msg)

0 commit comments

Comments
 (0)