From: Joe Perches <joe@perches.com>
To: David Miller <davem@davemloft.net>
Cc: nikolay@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH -net] netpoll: fix NULL pointer dereference in netpoll_cleanup
Date: Wed, 18 Sep 2013 09:25:24 -0700 [thread overview]
Message-ID: <1379521524.1787.44.camel@joe-AO722> (raw)
In-Reply-To: <20130918.121539.1213515779326200577.davem@davemloft.net>
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 ...;
}
next prev parent reply other threads:[~2013-09-18 16:25 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 [this message]
2013-09-18 21:09 ` Nikolay Aleksandrov
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=1379521524.1787.44.camel@joe-AO722 \
--to=joe@perches.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nikolay@redhat.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 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).