Commit 9bdc112b authored by Yuan Can's avatar Yuan Can Committed by Guenter Roeck

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: d0ddfd24 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20221125014329.121560-1-yuancan@huawei.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 7dec1453
...@@ -938,6 +938,8 @@ static int asus_ec_probe(struct platform_device *pdev) ...@@ -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->nr_sensors = hweight_long(ec_data->board_info->sensors);
ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors, ec_data->sensors = devm_kcalloc(dev, ec_data->nr_sensors,
sizeof(struct ec_sensor), GFP_KERNEL); sizeof(struct ec_sensor), GFP_KERNEL);
if (!ec_data->sensors)
return -ENOMEM;
status = setup_lock_data(dev); status = setup_lock_data(dev);
if (status) { if (status) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment