tipc: fix bug on error path in tipc_topsrv_kern_subscr()
authorJon Maloy <jon.maloy@ericsson.com>
Mon, 19 Feb 2018 11:48:21 +0000 (12:48 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Feb 2018 19:38:08 +0000 (14:38 -0500)
In commit cc1ea9ffadf7 ("tipc: eliminate struct tipc_subscriber") we
re-introduced an old bug on the error path in the function
tipc_topsrv_kern_subscr(). We now re-introduce the correction too.

Reported-by: syzbot+f62e0f2a0ef578703946@syzkaller.appspotmail.com
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/topsrv.c

index 02013e00f287628f6b9d80a42489e2e8328c5259..25925be1cc08bdf14cf81c1a530258a5be352fd0 100644 (file)
@@ -580,9 +580,10 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
        *conid = con->conid;
        con->sock = NULL;
        rc = tipc_conn_rcv_sub(tipc_topsrv(net), con, &sub);
-       if (rc < 0)
-               tipc_conn_close(con);
-       return !rc;
+       if (rc >= 0)
+               return true;
+       conn_put(con);
+       return false;
 }
 
 void tipc_topsrv_kern_unsubscr(struct net *net, int conid)