[TIPC] net/tipc/port.c: fix NULL dereference
authorAdrian Bunk <bunk@stusta.de>
Wed, 1 Nov 2006 00:59:35 +0000 (16:59 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 1 Nov 2006 23:42:33 +0000 (15:42 -0800)
The correct order is: NULL check before dereference

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/port.c

index c1a1a76759b59259e87a7b12bc190e6c9fcc07cc..b7f3199523caaf846d0aa1479c69888426374040 100644 (file)
@@ -1136,11 +1136,12 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
        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)