Skip to contentSkip to conversation

iprule: Fix descriptor leak in flush_rule()

PATCH New Maks Mishin 1 participant 1 message Feb 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iprule: Fix descriptor leak in flush_rule()

Added closure of file descriptor rth2 when returning from function.

---
 ip/iprule.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
ip/iprule.c +3 -1
index e503e5c6..ce40726a 100644
@@ -534,8 +534,10 @@ static int flush_rule(struct nlmsghdr *n, void *arg)
 		n->nlmsg_type = RTM_DELRULE;
 		n->nlmsg_flags = NLM_F_REQUEST;
 
-		if (rtnl_open(&rth2, 0) < 0)
+		if (rtnl_open(&rth2, 0) < 0) {
+			rtnl_close(&rth2);
 			return -1;
+		}
 
 		if (rtnl_talk(&rth2, n, NULL) < 0)
 			return -2;
Signature · 1 line
2.30.2