summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuan Can <yuancan@huawei.com>2022-11-25 01:43:29 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-08 11:30:18 +0100
commita41ec58ac352fd176d5808af847663dc890f6053 (patch)
tree002a796bff058b8ce7cc333fc28702325d863a3f
parentf598da27acbeee414679cacd14294db3e273e3d2 (diff)
hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
[ Upstream commit 9bdc112be727cf1ba65be79541147f960c3349d8 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/hwmon/asus-ec-sensors.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index 81e688975c6a..a901e4e33d81 100644
--- 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) {