tipc: fix possible memory leak in tipc_udp_enable()
authorWei Yongjun <weiyongjun1@huawei.com>
Sat, 10 Sep 2016 00:56:55 +0000 (00:56 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Sep 2016 15:28:32 +0000 (11:28 -0400)
'ub' is malloced in tipc_udp_enable() and should be freed before
leaving from the error handling cases, otherwise it will cause
memory leak.

Fixes: ba5aa84a2d22 ("tipc: split UDP nl address parsing")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/udp_media.c

index dd274687a53d4b8c1458863151afea68515c9a69..d80cd3f7503f26b9fc3f6171c125152ac332115b 100644 (file)
@@ -665,7 +665,8 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
 
        if (!opts[TIPC_NLA_UDP_LOCAL] || !opts[TIPC_NLA_UDP_REMOTE]) {
                pr_err("Invalid UDP bearer configuration");
-               return -EINVAL;
+               err = -EINVAL;
+               goto err;
        }
 
        err = tipc_parse_udp_addr(opts[TIPC_NLA_UDP_LOCAL], &local,