tipc: check return value of __tipc_dump_start()
authorCong Wang <[email protected]>
Tue, 11 Sep 2018 22:12:17 +0000 (15:12 -0700)
committerDavid S. Miller <[email protected]>
Wed, 12 Sep 2018 20:15:04 +0000 (13:15 -0700)
When __tipc_dump_start() fails with running out of memory,
we have no reason to continue, especially we should avoid
calling tipc_dump_done().

Fixes: 8f5c5fcf3533 ("tipc: call start and done ops directly in __tipc_nl_compat_dumpit()")
Reported-and-tested-by: [email protected]
Cc: Jon Maloy <[email protected]>
Cc: Ying Xue <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Ying Xue <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/tipc/netlink_compat.c

index 82f665728382115cba57cea441a89be2e911ed43..6376467e78f862c25ffae531848bd7aded07609e 100644 (file)
@@ -185,7 +185,10 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
                return -ENOMEM;
 
        buf->sk = msg->dst_sk;
-       __tipc_dump_start(&cb, msg->net);
+       if (__tipc_dump_start(&cb, msg->net)) {
+               kfree_skb(buf);
+               return -ENOMEM;
+       }
 
        do {
                int rem;