From: David Miller <davem@davemloft.net>
To: wangyufen@huawei.com
Cc: siva.kallam@broadcom.com, prashant@broadcom.com,
mchan@broadcom.com, netdev@vger.kernel.org
Subject: Re: [PATCH] tg3: Avoid NULL pointer dereference in tg3_get_nstats()
Date: Thu, 05 Jan 2017 12:33:37 -0500 (EST) [thread overview]
Message-ID: <20170105.123337.2237827308340782208.davem@davemloft.net> (raw)
In-Reply-To: <1483625601-10552-1-git-send-email-wangyufen@huawei.com>
From: Wang Yufen <wangyufen@huawei.com>
Date: Thu, 5 Jan 2017 22:13:21 +0800
> From: Yufen Wang <wangyufen@huawei.com>
>
> A possible NULL pointer dereference in tg3_get_stats64 while doing
> tg3_free_consistent.
...
> This patch avoids the NULL pointer dereference by using !tg3_flag(tp, INIT_COMPLETE)
> instate of !tp->hw_stats.
>
> Signed-off-by: Yufen Wang <wangyufen@huawei.com>
> ---
> drivers/net/ethernet/broadcom/tg3.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 185e9e0..012f18d 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -14148,7 +14148,7 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
> struct tg3 *tp = netdev_priv(dev);
>
> spin_lock_bh(&tp->lock);
> - if (!tp->hw_stats) {
> + if (!tg3_flag(tp, INIT_COMPLETE)) {
The real issue is the manner and order in which the driver performs
initialization actions relative to netif_device_{attach,detach}().
That is what needs to be fixed here, instead of adding more and more
ad-hoc tests to the various methods which can be invoked once the
netif_device_attach() occurs.
next prev parent reply other threads:[~2017-01-05 17:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 14:13 [PATCH] tg3: Avoid NULL pointer dereference in tg3_get_nstats() Wang Yufen
2017-01-05 17:33 ` David Miller [this message]
2017-01-05 20:04 ` Michael Chan
2017-01-05 20:17 ` David Miller
2017-01-05 21:53 ` Michael Chan
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=20170105.123337.2237827308340782208.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=prashant@broadcom.com \
--cc=siva.kallam@broadcom.com \
--cc=wangyufen@huawei.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