tipc: fix a potential oops
authorYing Xue <ying.xue@windriver.com>
Thu, 28 Aug 2014 02:02:41 +0000 (10:02 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Aug 2014 03:22:43 +0000 (20:22 -0700)
Commit 6c9808ce09f7 ("tipc: remove port_lock") accidentally involves
a potential bug: when tipc socket instance(tsk) is not got with given
reference number in tipc_sk_get(), tsk is set to NULL. Subsequently
we jump to exit label where to decrease socket reference counter
pointed by tsk pointer in tipc_sk_put(). However, As now tsk is NULL,
oops may happen because of touching a NULL pointer.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Erik Hugne <erik.hugne@ericsson.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c

index d416e83ce069adcbeb332850cfed68aca3fdba94..75275c5cf9291a0afe0818b6ef99ccfc14db8822 100644 (file)
@@ -2118,9 +2118,9 @@ static void tipc_sk_timeout(unsigned long ref)
 
        tsk = tipc_sk_get(ref);
        if (!tsk)
-               goto exit;
-       sk = &tsk->sk;
+               return;
 
+       sk = &tsk->sk;
        bh_lock_sock(sk);
        if (!tsk->connected) {
                bh_unlock_sock(sk);