]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tipc: fix memory leak in tipc_nl_compat_publ_dump
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Sat, 5 Jan 2019 16:52:23 +0000 (10:52 -0600)
committerDavid S. Miller <davem@davemloft.net>
Mon, 7 Jan 2019 16:42:08 +0000 (11:42 -0500)
There is a memory leak in case genlmsg_put fails.

Fix this by freeing *args* before return.

Addresses-Coverity-ID: 1476406 ("Resource leak")
Fixes: 46273cf7e009 ("tipc: fix a missing check of genlmsg_put")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/netlink_compat.c

index 40f5cae623a77d73a34f05f1974c8a3292c18f83..77e4b2418f302555acac4813d3baa39b356e632e 100644 (file)
@@ -904,8 +904,10 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
 
        hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI,
                          TIPC_NL_PUBL_GET);
-       if (!hdr)
+       if (!hdr) {
+               kfree_skb(args);
                return -EMSGSIZE;
+       }
 
        nest = nla_nest_start(args, TIPC_NLA_SOCK);
        if (!nest) {