From: Nikolay Aleksandrov <nikolay@redhat.com>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH -net] netpoll: fix NULL pointer dereference in netpoll_cleanup
Date: Wed, 18 Sep 2013 23:09:11 +0200 [thread overview]
Message-ID: <523A1677.2090602@redhat.com> (raw)
In-Reply-To: <1379521524.1787.44.camel@joe-AO722>
On 09/18/2013 06:25 PM, Joe Perches wrote:
> On Wed, 2013-09-18 at 12:15 -0400, 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.
>
> Another alternative is:
>
> lock();
>
> if (!condition)
> goto out;
>
> ...
>
> out:
> unlock();
> return ...;
> }
>
Yup, this is the alternative I plan to use :-)
Thanks Joe
next prev parent reply other threads:[~2013-09-18 21:09 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 [this message]
2013-09-18 21:06 ` Nikolay Aleksandrov
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=523A1677.2090602@redhat.com \
--to=nikolay@redhat.com \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--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).