Skip to content

Commit

Permalink
hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
Browse files Browse the repository at this point in the history
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]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
Yuan Can authored and zeule committed Jan 21, 2023
1 parent b8b17e6 commit 94cf50a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions asus-ec-sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 94cf50a

Please sign in to comment.