netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/1] NET: ipv6, fix potential null dereference
@ 2010-01-10 10:35 Alexey Dobriyan
  2010-01-10 10:38 ` Jiri Slaby
  2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
  0 siblings, 2 replies; 8+ messages in thread
From: Alexey Dobriyan @ 2010-01-10 10:35 UTC (permalink / raw)
  To: jslaby; +Cc: netdev

> Stanse found a potential null dereference

Nobody learns from Coverity, it seems. :^)

snmp6_unregister_dev() always called with valid idev.

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH 1/1] NET: ipv6, fix potential null dereference
@ 2010-01-10  9:06 Jiri Slaby
  0 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2010-01-10  9:06 UTC (permalink / raw)
  To: davem
  Cc: linux-kernel, jirislaby, Alexey Kuznetsov, Pekka Savola (ipv6),
	James Morris, Hideaki YOSHIFUJI, Patrick McHardy, netdev

Stanse found a potential null dereference in snmp6_unregister_dev.
There is a check for idev being NULL, but it is dereferenced
earlier. Move the dereference after the check.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: "Pekka Savola (ipv6)" <pekkas@netcore.fi>
Cc: James Morris <jmorris@namei.org>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: netdev@vger.kernel.org
---
 net/ipv6/proc.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index c9605c3..53f4ef5 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -256,11 +256,12 @@ int snmp6_register_dev(struct inet6_dev *idev)
 
 int snmp6_unregister_dev(struct inet6_dev *idev)
 {
-	struct net *net = dev_net(idev->dev);
-	if (!net->mib.proc_net_devsnmp6)
-		return -ENOENT;
+	struct net *net;
 	if (!idev || !idev->stats.proc_dir_entry)
 		return -EINVAL;
+	net = dev_net(idev->dev);
+	if (!net->mib.proc_net_devsnmp6)
+		return -ENOENT;
 	remove_proc_entry(idev->stats.proc_dir_entry->name,
 			  net->mib.proc_net_devsnmp6);
 	idev->stats.proc_dir_entry = NULL;
-- 
1.6.5.7

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

end of thread, other threads:[~2010-01-10 21:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 10:35 [PATCH 1/1] NET: ipv6, fix potential null dereference Alexey Dobriyan
2010-01-10 10:38 ` Jiri Slaby
2010-01-10 10:47   ` Alexey Dobriyan
2010-01-10 11:05     ` Jiri Slaby
2010-01-10 11:37       ` Jiri Slaby
2010-01-10 10:43 ` [PATCH 1/1] NET: ipv6, remove unnecessary check Jiri Slaby
2010-01-10 21:28   ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2010-01-10  9:06 [PATCH 1/1] NET: ipv6, fix potential null dereference Jiri Slaby

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