Skip to content

Commit 9bdc112

Browse files
Yuan Cangroeck
authored andcommitted
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: d0ddfd2 ("hwmon: (asus-ec-sensors) add driver for ASUS EC") Signed-off-by: Yuan Can <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 7dec145 commit 9bdc112

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/hwmon/asus-ec-sensors.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ static int asus_ec_probe(struct platform_device *pdev)
938938
ec_data->nr_sensors = hweight_long(ec_data->board_info->sensors);
939939
ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors,
940940
sizeof(struct ec_sensor), GFP_KERNEL);
941+
if (!ec_data->sensors)
942+
return -ENOMEM;
941943

942944
status = setup_lock_data(dev);
943945
if (status) {

0 commit comments

Comments
 (0)