All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCHv2] usbnet: fix memory leak in error case
Date: Wed, 29 Jun 2022 20:36:33 -0700	[thread overview]
Message-ID: <20220629203633.56382dca@kernel.org> (raw)
In-Reply-To: <20220628083128.28472-1-oneukum@suse.com>

On Tue, 28 Jun 2022 10:31:28 +0200 Oliver Neukum wrote:
> -	void *buf = NULL;
> +	void *buf;
>  
>  	netdev_dbg(dev->net, "usbnet_write_cmd cmd=0x%02x reqtype=%02x"
>  		   " value=0x%04x index=0x%04x size=%d\n",
> @@ -2155,7 +2155,7 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
>  		if (!buf) {
>  			netdev_err(dev->net, "Error allocating buffer"
>  				   " in %s!\n", __func__);
> -			goto fail_free;
> +			goto fail_free_urb;
>  		}
>  	}
>  
> @@ -2179,14 +2179,21 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
>  	if (err < 0) {
>  		netdev_err(dev->net, "Error submitting the control"
>  			   " message: status=%d\n", err);
> -		goto fail_free;
> +		goto fail_free_all;
>  	}
>  	return 0;
>  
> +fail_free_all:
> +	kfree(req);
>  fail_free_buf:
>  	kfree(buf);

Seems like the buf can be uninitialized now if data was NULL

  reply	other threads:[~2022-06-30  3:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  8:31 [PATCHv2] usbnet: fix memory leak in error case Oliver Neukum
2022-06-30  3:36 ` Jakub Kicinski [this message]
2022-07-05 12:54   ` Oliver Neukum

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=20220629203633.56382dca@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oneukum@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.