netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH -net] netpoll: fix NULL pointer dereference in netpoll_cleanup
Date: Wed, 18 Sep 2013 23:06:57 +0200	[thread overview]
Message-ID: <523A15F1.60306@redhat.com> (raw)
In-Reply-To: <20130918.121539.1213515779326200577.davem@davemloft.net>

On 09/18/2013 06:15 PM, David Miller wrote:
> From: Nikolay Aleksandrov <nikolay@redhat.com>
> Date: Tue, 17 Sep 2013 16:12:35 +0200
> 
>> @@ -1284,15 +1284,15 @@ EXPORT_SYMBOL_GPL(__netpoll_free_async);
>>  
>>  void netpoll_cleanup(struct netpoll *np)
>>  {
>> -	if (!np->dev)
>> -		return;
>> -
>>  	rtnl_lock();
>> +	if (!np->dev) {
>> +		rtnl_unlock();
>> +		return;
>> +	}
>>  	__netpoll_cleanup(np);
>> -	rtnl_unlock();
>> -
>>  	dev_put(np->dev);
>>  	np->dev = NULL;
>> +	rtnl_unlock();
>>  }
>>  EXPORT_SYMBOL(netpoll_cleanup);
> 
> I know it seems arbitrary, but please do this like:
> 
> 	lock();
> 	if (condition) {
> 		...
> 	}
> 	unlock();
> 
> rather than having multiple return/unlock code paths.
> 
> This style I am suggesting is easier to audit for locking problems.
> 
> Thanks.
> 
Got it, I'll edit it and re-post.

Thanks,
 Nik

      parent reply	other threads:[~2013-09-18 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 14:12 [PATCH -net] netpoll: fix NULL pointer dereference in netpoll_cleanup Nikolay Aleksandrov
2013-09-17 14:37 ` Nikolay Aleksandrov
2013-09-17 18:06   ` Nikolay Aleksandrov
2013-09-18 16:15 ` David Miller
2013-09-18 16:25   ` Joe Perches
2013-09-18 21:09     ` Nikolay Aleksandrov
2013-09-18 21:06   ` Nikolay Aleksandrov [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=523A15F1.60306@redhat.com \
    --to=nikolay@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@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).