projects
/
platform
/
kernel
/
linux-starfive.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7dec145
)
hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
author
Yuan Can
<yuancan@huawei.com>
Fri, 25 Nov 2022 01:43:29 +0000
(
01:43
+0000)
committer
Guenter Roeck
<linux@roeck-us.net>
Thu, 1 Dec 2022 17:20:55 +0000
(09:20 -0800)
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 <yuancan@huawei.com>
Link:
https://lore.kernel.org/r/20221125014329.121560-1-yuancan@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/asus-ec-sensors.c
patch
|
blob
|
history
diff --git
a/drivers/hwmon/asus-ec-sensors.c
b/drivers/hwmon/asus-ec-sensors.c
index
81e6889
..
a901e4e
100644
(file)
--- a/
drivers/hwmon/asus-ec-sensors.c
+++ b/
drivers/hwmon/asus-ec-sensors.c
@@
-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) {