netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IPv6: Fix Smatch warning.
@ 2012-03-08  0:58 Li Wei
  2012-03-11 22:57 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Li Wei @ 2012-03-08  0:58 UTC (permalink / raw)
  To: David S. Miller; +Cc: Dan Carpenter, netdev


With commit d6ddef9e641d(IPv6: Fix not join all-router mcast group
when forwarding set.) I check 'dev' after it's dereference that
leads to a Smatch complaint:

net/ipv6/addrconf.c:438 ipv6_add_dev()
	 warn: variable dereferenced before check 'dev' (see line 432)

net/ipv6/addrconf.c
   431		/* protected by rtnl_lock */
   432		rcu_assign_pointer(dev->ip6_ptr, ndev);
                                   ^^^^^^^^^^^^
Old dereference.

   433
   434		/* Join all-node multicast group */
   435		ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
   436
   437		/* Join all-router multicast group if forwarding is set
*/
   438		if (ndev->cnf.forwarding && dev && (dev->flags &
IFF_MULTICAST))
                                            ^^^

Remove the check to avoid the complaint as 'dev' can't be NULL.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Li Wei <lw@cn.fujitsu.com>
---
 net/ipv6/addrconf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6b8ebc5..6a3bb60 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -435,7 +435,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
 	ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
 
 	/* Join all-router multicast group if forwarding is set */
-	if (ndev->cnf.forwarding && dev && (dev->flags & IFF_MULTICAST))
+	if (ndev->cnf.forwarding && (dev->flags & IFF_MULTICAST))
 		ipv6_dev_mc_inc(dev, &in6addr_linklocal_allrouters);
 
 	return ndev;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] IPv6: Fix Smatch warning.
  2012-03-08  0:58 [PATCH] IPv6: Fix Smatch warning Li Wei
@ 2012-03-11 22:57 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-03-11 22:57 UTC (permalink / raw)
  To: lw; +Cc: dan.carpenter, netdev

From: Li Wei <lw@cn.fujitsu.com>
Date: Thu, 08 Mar 2012 08:58:07 +0800

> 
> With commit d6ddef9e641d(IPv6: Fix not join all-router mcast group
> when forwarding set.) I check 'dev' after it's dereference that
> leads to a Smatch complaint:
> 
> net/ipv6/addrconf.c:438 ipv6_add_dev()
> 	 warn: variable dereferenced before check 'dev' (see line 432)
 ...
> Remove the check to avoid the complaint as 'dev' can't be NULL.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Li Wei <lw@cn.fujitsu.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-11 22:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08  0:58 [PATCH] IPv6: Fix Smatch warning Li Wei
2012-03-11 22:57 ` David Miller

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).