tipc: fix error handling in tipc_udp_enable()
authorWei Yongjun <weiyongjun1@huawei.com>
Mon, 26 Mar 2018 14:32:44 +0000 (14:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 27 Mar 2018 14:50:02 +0000 (10:50 -0400)
Release alloced resource before return from the error handling
case in tipc_udp_enable(), otherwise will cause memory leak.

Fixes: 52dfae5c85a4 ("tipc: obtain node identity from interface by default")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/udp_media.c

index 2c13b18..e7d91f5 100644 (file)
@@ -687,7 +687,8 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
        }
        if (!tipc_own_id(net)) {
                pr_warn("Failed to set node id, please configure manually\n");
-               return -EINVAL;
+               err = -EINVAL;
+               goto err;
        }
 
        b->bcast_addr.media_id = TIPC_MEDIA_TYPE_UDP;