Skip to contentSkip to conversation

tipc: check return value of __tipc_dump_start()

PATCH Applied Cong Wang 3 participants 3 messages Sep 12, 2018 – Sep 13, 2018

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 tipc: check return value of __tipc_dump_start()

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]>
---
 net/tipc/netlink_compat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/tipc/netlink_compat.c +4 -1
index 82f665728382..6376467e78f8 100644
@@ -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;
Signature · 1 line
2.14.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Cong Wang

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]>
Quoted 21 lines
---
 net/tipc/netlink_compat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/tipc/netlink_compat.c +4 -1
index 82f665728382..6376467e78f8 100644
@@ -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;
maintainer Applied
#2 lore raw
In reply to Cong Wang

From: Cong Wang <[email protected]>
Date: Tue, 11 Sep 2018 15:12:17 -0700

Quoted 9 lines

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]>

Applied, thanks Cong.