linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ji-Hun Kim <ji_hun.kim@samsung.com>
Cc: devel@driverdev.osuosl.org, y.k.oh@samsung.com,
	gregkh@linuxfoundation.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org, julia.lawall@lip6.fr,
	baijiaju1990@gmail.com, forest@alittletooquiet.net,
	santhameena13@gmail.com
Subject: Re: [PATCH v4 2/2] staging: vt6655: add handling memory leak on vnt_start()
Date: Tue, 3 Apr 2018 14:18:33 +0300	[thread overview]
Message-ID: <20180403111833.r6o3xf4go5gfwyj6@mwanda> (raw)
In-Reply-To: <1522389115-1124-2-git-send-email-ji_hun.kim@samsung.com>

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@samsung.com>
> ---
> 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

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2018-04-03 11:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180330055207epcas1p14d562f44802bac86a8a7cd95fe2d009f@epcas1p1.samsung.com>
2018-03-30  5:51 ` [PATCH v4 1/2] staging: vt6655: check for memory allocation failures Ji-Hun Kim
     [not found]   ` <CGME20180330055211epcas2p1a75c707cdf600cfd5027e253ef440861@epcas2p1.samsung.com>
2018-03-30  5:51     ` [PATCH v4 2/2] staging: vt6655: add handling memory leak on vnt_start() Ji-Hun Kim
2018-04-03 11:18       ` Dan Carpenter [this message]
2018-04-01  2:42   ` [PATCH v4 1/2] staging: vt6655: check for memory allocation failures Jia-Ju Bai
2018-04-03 11:12   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180403111833.r6o3xf4go5gfwyj6@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=baijiaju1990@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ji_hun.kim@samsung.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=santhameena13@gmail.com \
    --cc=y.k.oh@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).