Re: [PATCH v8 02/13] squash! max9286: convert probe kzalloc

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

 



Hi Kieran,

Thank you for the patch.

On Thu, Apr 09, 2020 at 01:11:51PM +0100, Kieran Bingham wrote:
> v8:
>  - Convert probe kzalloc usage to devm_ variant

This isn't worse than the existing code, but are you aware that devm_*
should not be used in this case ? The memory should be allocated with
kzalloc() and freed in the .release() operation.

> ---
>  drivers/media/i2c/max9286.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index b84d2daa6561..0a43137b8112 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -1155,7 +1155,7 @@ static int max9286_probe(struct i2c_client *client)
>  	unsigned int i;
>  	int ret;
>  
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> +	priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		return -ENOMEM;
>  
> @@ -1232,7 +1232,6 @@ static int max9286_probe(struct i2c_client *client)
>  	max9286_configure_i2c(priv, false);
>  err_free:
>  	max9286_cleanup_dt(priv);
> -	kfree(priv);
>  
>  	return ret;
>  }
> @@ -1253,8 +1252,6 @@ static int max9286_remove(struct i2c_client *client)
>  
>  	gpiod_set_value_cansleep(priv->gpiod_pwdn, 0);
>  
> -	kfree(priv);
> -
>  	return 0;
>  }
>  

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux