hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
Subsystems (2)
PATCH 1/1 hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
As the devm_kcalloc may return NULL, the return value needs to be checked to avoid NULL poineter dereference.
Fixes d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
Signed-off-by Yuan Can <[email protected]>
--- drivers/hwmon/asus-ec-sensors.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/asus-ec-sensors.c +2 -0
@@ -938,6 +938,8 @@ static int asus_ec_probe(struct platform_device *pdev) ec_data->nr_sensors =hweight_long (ec_data->board_info->sensors); ec_data->sensors =devm_kcalloc (dev, ec_data->nr_sensors,sizeof (struct ec_sensor ),GFP_KERNEL ); +if (!ec_data->sensors) +return -ENOMEM ; status =setup_lock_data (dev);if (status) {
Signature · 1 line
2.17.1
Quoted 5 lines · Yuan Can
As the
devm_kcallocmay return NULL, the return value needs to be checked to avoid NULL poineter dereference.Fixes d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")Signed-off-by Yuan Can <[email protected]>
Applied.
Thanks,
Guenter
Quoted 17 lines
--- drivers/hwmon/asus-ec-sensors.c | 2 ++ 1 file changed, 2 insertions(+)drivers/hwmon/asus-ec-sensors.c +2
-0@@ -938,6 +938,8 @@ static int asus_ec_probe(struct platform_device *pdev) ec_data->nr_sensors =hweight_long (ec_data->board_info->sensors); ec_data->sensors =devm_kcalloc (dev, ec_data->nr_sensors,sizeof (struct ec_sensor ),GFP_KERNEL ); +if (!ec_data->sensors) +return -ENOMEM ; status =setup_lock_data (dev);if (status) {