Re: [PATCH v4 2/2] staging: vt6655: add handling memory leak on vnt_start()

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

 



On Fri, Mar 30, 2018 at 02:51:55PM +0900, Ji-Hun Kim wrote:
> There was no code for handling memory leaks of device_init_rings() and
> request_irq(). It needs to free allocated memory in the device_init_rings()
> , when request_irq() is failed. Add freeing sequences of irq and device
> init rings.
> 
> Signed-off-by: Ji-Hun Kim <ji_hun.kim@xxxxxxxxxxx>
> ---
> It's additional memory leak handling patch from
> [PATCH v4 1/2] staging: vt6655: check for memory allocation failures
> 
>  drivers/staging/vt6655/device_main.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> index c9752df..3604f2d 100644
> --- a/drivers/staging/vt6655/device_main.c
> +++ b/drivers/staging/vt6655/device_main.c
> @@ -1194,14 +1194,17 @@ static int vnt_start(struct ieee80211_hw *hw)
>  	int ret;
>  
>  	priv->rx_buf_sz = PKT_BUF_SZ;
> -	if (!device_init_rings(priv))
> -		return -ENOMEM;
> +	ret = (int)device_init_rings(priv);

There is only one call site.  Just change device_init_rings() to return
negative error codes or zero.

> +	if (!ret) {
> +		ret = -ENOMEM;
> +		goto err_init_rings;

Just return directly since there is nothing to clean up.

		return -ENOMEM;

> +	}
>  
>  	ret = request_irq(priv->pcid->irq, vnt_interrupt,
>  			  IRQF_SHARED, "vt6655", priv);
>  	if (ret) {
>  		dev_dbg(&priv->pcid->dev, "failed to start irq\n");
> -		return ret;
> +		goto err_irq;

This is a "come from" label name.  It's better if the goto says what the
goto does like "goto err_free_rings;" here.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux