linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Arend Van Spriel <arend.vanspriel@broadcom.com>,
	Eduardo Abinader <eabinader@ocedo.com>,
	linux-wireless@vger.kernel.org
Cc: Eduardo Abinader <eduardo.abinader@riverbed.com>
Subject: Re: [PATCH] nl80211: avoid possible memleak on nl80211_set_reg
Date: Thu, 09 Jun 2016 10:39:54 +0200	[thread overview]
Message-ID: <1465461594.3442.7.camel@sipsolutions.net> (raw)
In-Reply-To: <a961b2ee-b4fa-dec9-72ed-f9b600fa51b2@broadcom.com> (sfid-20160609_103604_383463_C1E1294A)


> > > +++ b/net/wireless/nl80211.c
> > > @@ -5839,10 +5839,11 @@ static int nl80211_set_reg(struct sk_buff
> > > *skb, struct genl_info *info)
> > >  
> > >  	r = set_regdom(rd, REGD_SOURCE_CRDA);
> > >  	/* set_regdom took ownership */
> > > -	rd = NULL;
> > >  
> > >   bad_reg:
> > >  	kfree(rd);
> > > +	rd = NULL;
> > To this I can only say: what?
> The patch is bad, but the confusion starts with the original code
> (ab)using kfree() behaviour by setting rd to NULL. Personally, I do
> not like it, but prefer it over bugs ;-)
> 

Yeah, fair enough. I'll make the following patch:

-	r = set_regdom(rd, REGD_SOURCE_CRDA);
-	/* set_regdom took ownership */
-	rd = NULL;
+	/* set_regdom takes ownership of rd */
+	return set_regdom(rd, REGD_SOURCE_CRDA);

johannes

  reply	other threads:[~2016-06-09  8:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 14:56 [PATCH] nl80211: avoid possible memleak on nl80211_set_reg Eduardo Abinader
2016-06-09  7:58 ` Johannes Berg
2016-06-09  8:36   ` Arend Van Spriel
2016-06-09  8:39     ` Johannes Berg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-06-06 14:46 Eduardo Abinader

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=1465461594.3442.7.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=arend.vanspriel@broadcom.com \
    --cc=eabinader@ocedo.com \
    --cc=eduardo.abinader@riverbed.com \
    --cc=linux-wireless@vger.kernel.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).