瀏覽代碼

[TIPC] net/tipc/port.c: fix NULL dereference

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>
Adrian Bunk 18 年之前
父節點
當前提交
d55b4c631e
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      net/tipc/port.c

+ 3 - 2
net/tipc/port.c

@@ -1136,11 +1136,12 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
 	int res = -EINVAL;
 	int res = -EINVAL;
 
 
 	p_ptr = tipc_port_lock(ref);
 	p_ptr = tipc_port_lock(ref);
+	if (!p_ptr)
+		return -EINVAL;
+
 	dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
 	dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
 	    "lower = %u, upper = %u\n",
 	    "lower = %u, upper = %u\n",
 	    ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
 	    ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
-	if (!p_ptr)
-		return -EINVAL;
 	if (p_ptr->publ.connected)
 	if (p_ptr->publ.connected)
 		goto exit;
 		goto exit;
 	if (seq->lower > seq->upper)
 	if (seq->lower > seq->upper)