mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 04:47:05 +00:00
hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
[ Upstream commit9bdc112be7
] As the devm_kcalloc may return NULL, the return value needs to be checked to avoid NULL poineter dereference. Fixes:d0ddfd241e
("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>
This commit is contained in:
parent
f598da27ac
commit
a41ec58ac3
1 changed files with 2 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue