summary refs log tree commit diff
diff options
context:
space:
mode:
authorYiyuan Guo <yguoaz@gmail.com>2023-06-30 22:37:19 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-16 18:27:24 +0200
commit366563c14f1f8871fcf590d23e2f645fc81340d9 (patch)
tree8aae42f0eee8be263b050bf37f904e3941fc9cb2
parent5aac2726b6930f9d5dffb1090ebfc0cdfad6a30c (diff)
downloadlinux-366563c14f1f8871fcf590d23e2f645fc81340d9.tar.gz
iio: cros_ec: Fix the allocation size for cros_ec_command
commit 8a4629055ef55177b5b63dab1ecce676bd8cccdd upstream.

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 <tzungbi@kernel.org>
Signed-off-by: Yiyuan Guo <yguoaz@gmail.com>
Fixes: 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.")
Link: https://lore.kernel.org/r/20230630143719.1513906-1-yguoaz@gmail.com
Cc: <Stable@vger.kerenl.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index 05a28d353e34..d98f7e4d202c 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -253,7 +253,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 	platform_set_drvdata(pdev, indio_dev);
 
 	state->ec = ec->ec_dev;
-	state->msg = devm_kzalloc(&pdev->dev,
+	state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) +
 				max((u16)sizeof(struct ec_params_motion_sense),
 				state->ec->max_response), GFP_KERNEL);
 	if (!state->msg)