public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] net/tipc/port.c: fix NULL dereference
@ 2006-11-01  0:40 Adrian Bunk
  2006-11-01  0:59 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2006-11-01  0:40 UTC (permalink / raw)
  To: per.liden, jon.maloy, allan.stephens
  Cc: tipc-discussion, netdev, linux-kernel

The correct order is: NULL check before dereference

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6/net/tipc/port.c.old	2006-11-01 00:37:58.000000000 +0100
+++ linux-2.6/net/tipc/port.c	2006-11-01 00:38:27.000000000 +0100
@@ -1136,11 +1136,12 @@
 	int res = -EINVAL;
 
 	p_ptr = tipc_port_lock(ref);
+	if (!p_ptr)
+		return -EINVAL;
+
 	dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
 	    "lower = %u, upper = %u\n",
 	    ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
-	if (!p_ptr)
-		return -EINVAL;
 	if (p_ptr->publ.connected)
 		goto exit;
 	if (seq->lower > seq->upper)


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

* Re: [2.6 patch] net/tipc/port.c: fix NULL dereference
  2006-11-01  0:40 [2.6 patch] net/tipc/port.c: fix NULL dereference Adrian Bunk
@ 2006-11-01  0:59 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2006-11-01  0:59 UTC (permalink / raw)
  To: bunk
  Cc: per.liden, jon.maloy, allan.stephens, tipc-discussion, netdev,
	linux-kernel

From: Adrian Bunk <bunk@stusta.de>
Date: Wed, 1 Nov 2006 01:40:37 +0100

> The correct order is: NULL check before dereference
> 
> Spotted by the Coverity checker.
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>

Applied, thanks Adrian.

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

end of thread, other threads:[~2006-11-01  0:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-01  0:40 [2.6 patch] net/tipc/port.c: fix NULL dereference Adrian Bunk
2006-11-01  0:59 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox