netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Cc: "John W. Linville"
	<linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] cfg80211: fix error path in cfg80211_wext_siwscan
Date: Wed, 23 Dec 2009 16:46:05 +0200	[thread overview]
Message-ID: <20091223144605.GA23721@bicker> (raw)
In-Reply-To: <1261578815.7304.7.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>

On Wed, Dec 23, 2009 at 03:33:35PM +0100, Johannes Berg wrote:
> If there's an invalid channel or SSID, the code leaks
> the scan request. Always free the scan request, unless
> it was successfully given to the driver.
> 
> Reported-by: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
> ---
> I kinda prefer this, thoughts?
> 

Looks good.

Acked-by: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

regards,
dan carpenter

>  net/wireless/scan.c |   13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> --- wireless-testing.orig/net/wireless/scan.c	2009-12-23 15:27:20.000000000 +0100
> +++ wireless-testing/net/wireless/scan.c	2009-12-23 15:32:52.000000000 +0100
> @@ -601,7 +601,7 @@ int cfg80211_wext_siwscan(struct net_dev
>  	struct cfg80211_registered_device *rdev;
>  	struct wiphy *wiphy;
>  	struct iw_scan_req *wreq = NULL;
> -	struct cfg80211_scan_request *creq;
> +	struct cfg80211_scan_request *creq = NULL;
>  	int i, err, n_channels = 0;
>  	enum ieee80211_band band;
>  
> @@ -694,8 +694,10 @@ int cfg80211_wext_siwscan(struct net_dev
>  	/* translate "Scan for SSID" request */
>  	if (wreq) {
>  		if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
> -			if (wreq->essid_len > IEEE80211_MAX_SSID_LEN)
> -				return -EINVAL;
> +			if (wreq->essid_len > IEEE80211_MAX_SSID_LEN) {
> +				err = -EINVAL;
> +				goto out;
> +			}
>  			memcpy(creq->ssids[0].ssid, wreq->essid, wreq->essid_len);
>  			creq->ssids[0].ssid_len = wreq->essid_len;
>  		}
> @@ -707,12 +709,15 @@ int cfg80211_wext_siwscan(struct net_dev
>  	err = rdev->ops->scan(wiphy, dev, creq);
>  	if (err) {
>  		rdev->scan_req = NULL;
> -		kfree(creq);
> +		/* creq will be freed below */
>  	} else {
>  		nl80211_send_scan_start(rdev, dev);
> +		/* creq now owned by driver */
> +		creq = NULL;
>  		dev_hold(dev);
>  	}
>   out:
> +	kfree(creq);
>  	cfg80211_unlock_rdev(rdev);
>  	return err;
>  }
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2009-12-23 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23 13:29 [patch] fix error paths in cfg80211_wext_siwscan() Dan Carpenter
2009-12-23 14:33 ` [PATCH] cfg80211: fix error path in cfg80211_wext_siwscan Johannes Berg
     [not found]   ` <1261578815.7304.7.camel-YfaajirXv2244ywRPIzf9A@public.gmane.org>
2009-12-23 14:46     ` Dan Carpenter [this message]

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=20091223144605.GA23721@bicker \
    --to=error27-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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).