Re: [PATCH] hwmon: (asus-ec-sensors) Add checks for devm_kcalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 25, 2022 at 01:43:29AM +0000, Yuan Can wrote:
> 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@xxxxxxxxxx>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/asus-ec-sensors.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> 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) {



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux