diff mbox series

[iproute] iplink: emit the error message if open_fds_add failed

Message ID 20250121141642.28899-1-kirjanov@gmail.com (mailing list archive)
State New
Delegated to: Stephen Hemminger
Headers show
Series [iproute] iplink: emit the error message if open_fds_add failed | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Denis Kirjanov Jan. 21, 2025, 2:16 p.m. UTC
open_fds_add may fail since it adds an open fd
to the fixed array. Print the error message in
the such case.

Signed-off-by: Denis Kirjanov <kirjanov@gmail.com>
---
 ip/iplink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ip/iplink.c b/ip/iplink.c
index 59e8caf4..1396da23 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -666,7 +666,9 @@  int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 			if (netns < 0)
 				invarg("Invalid \"netns\" value\n", *argv);
 
-			open_fds_add(netns);
+			if (open_fds_add(netns))
+				invarg("No descriptors left\n", *argv);
+
 			addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_FD,
 				  &netns, 4);
 			move_netns = true;