linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: devel@driverdev.osuosl.org, Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org, Jia-Ju Bai <baijiaju1990@gmail.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Shreeya Patel <shreeya.patel23498@gmail.com>,
	Colin Ian King <colin.king@canonical.com>
Subject: Re: [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb
Date: Fri, 15 Jun 2018 13:15:25 +0200	[thread overview]
Message-ID: <20180615111525.GA27391@kroah.com> (raw)
In-Reply-To: <1528705874-34845-1-git-send-email-jiazhouyang09@gmail.com>

On Mon, Jun 11, 2018 at 04:31:11PM +0800, Zhouyang Jia wrote:
> When usb_alloc_urb fails, the lack of error-handling code may
> cause unexpected results.
> 
> This patch adds error-handling code after calling usb_alloc_urb.
> 
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
> index 7a0dbc0..3f09615 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -1666,6 +1666,9 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
>  		void *oldaddr, *newaddr;
>  
>  		priv->rx_urb[16] = usb_alloc_urb(0, GFP_KERNEL);
> +		if (!priv->rx_urb[16])
> +			return -ENOMEM;
> +

You just leaked memory :(

Well, this whole function leaks memory on the error paths, like here:

>  		priv->oldaddr = kmalloc(16, GFP_KERNEL);
>  		if (!priv->oldaddr)
>  			return -ENOMEM;

So can you fix this all up at the same time?

thanks,

greg k-h

  reply	other threads:[~2018-06-15 11:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11  8:31 [PATCH] staging: rtl8192u: add error handling for usb_alloc_urb Zhouyang Jia
2018-06-15 11:15 ` Greg Kroah-Hartman [this message]
2018-06-15 16:25 ` [PATCH v2] " Zhouyang Jia
2018-06-15 16:33   ` Greg Kroah-Hartman
2018-06-15 16:47     ` Kees Cook
2018-06-15 16:47       ` Kees Cook
2018-06-15 17:28 ` [PATCH v3] " Zhouyang Jia
2018-06-15 18:35   ` kbuild test robot
2018-06-15 23:17   ` Kees Cook
2018-06-16  2:01 ` [PATCH v4] " Zhouyang Jia
2018-06-16  8:11   ` Dan Carpenter
2018-06-16 15:47 ` [PATCH v5] " Zhouyang Jia

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=20180615111525.GA27391@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=baijiaju1990@gmail.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=jiazhouyang09@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shreeya.patel23498@gmail.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).