All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gertjan van Wingerde <gwingerde@gmail.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] NET: wireless, fix memory leak
Date: Wed, 06 Jan 2010 20:07:48 +0100	[thread overview]
Message-ID: <4B44DF84.80206@gmail.com> (raw)
In-Reply-To: <1262795743-15009-2-git-send-email-jslaby@suse.cz>

On 01/06/10 17:35, Jiri Slaby wrote:
> Stanse found a memory leak in cfg80211_wext_siwscan. creq is not
> freed/assigned on all paths. Fix that.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  net/wireless/scan.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/wireless/scan.c b/net/wireless/scan.c
> index 9c50c85..3003d13 100644
> --- a/net/wireless/scan.c
> +++ b/net/wireless/scan.c
> @@ -685,7 +685,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
>  	/* No channels found? */
>  	if (!i) {
>  		err = -EINVAL;
> -		goto out;
> +		goto out_free;
>  	}
>  
>  	/* Set real number of channels specified in creq->channels[] */
> @@ -696,7 +696,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
>  		if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
>  			if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) {
>  				err = -EINVAL;
> -				goto out;
> +				goto out_free;
>  			}
>  			memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len);
>  			creq->ssids[0].ssid_len = wreq->essid_len;
> @@ -717,6 +717,9 @@ int cfg80211_wext_siwscan(struct net_device *dev,
>   out:
>  	cfg80211_unlock_rdev(rdev);
>  	return err;
> +out_free:
> +	kfree(creq);
> +	goto out;
>  }
>  EXPORT_SYMBOL_GPL(cfg80211_wext_siwscan);
>  

This last part looks a bit strange. Why don't you put out_free label before out label,
and let it continue after the kfree, instead of jumping back to the out label.

---
Gertjan.


  parent reply	other threads:[~2010-01-06 19:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 16:35 [PATCH 1/2] net: wireless, fix lock imbalance Jiri Slaby
2010-01-06 16:35 ` [PATCH 2/2] NET: wireless, fix memory leak Jiri Slaby
2010-01-06 17:43   ` Luis R. Rodriguez
2010-01-06 19:07   ` Gertjan van Wingerde [this message]
2010-01-06 19:14     ` Jiri Slaby
2010-01-06 17:44 ` [PATCH 1/2] net: wireless, fix lock imbalance Luis R. Rodriguez
2010-01-06 19:55 ` John W. Linville
2010-01-06 20:30   ` Jiri Slaby

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=4B44DF84.80206@gmail.com \
    --to=gwingerde@gmail.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.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.