Skip to contentSkip to conversation

ctrl: Add check for result rtnl_dump_filter()

PATCH In review Maks Mishin 2 participants 2 messages Feb 18, 2024 – Feb 19, 2024

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

PATCH 1/1 ctrl: Add check for result rtnl_dump_filter()

Added check for result of rtnl_dump_filter() function for catch errors linked with dump.
Found by RASU JSC.

---
 genl/ctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
genl/ctrl.c +4 -1
index aff922a4..467a2830 100644
@@ -313,7 +313,10 @@ static int ctrl_list(int cmd, int argc, char **argv)
 			goto ctrl_done;
 		}
 
-		rtnl_dump_filter(&rth, print_ctrl2, stdout);
+		if (rtnl_dump_filter(&rth, print_ctrl2, stdout) < 0) {
+			fprintf(stderr, "Dump terminated\n");
+			exit(1);
+		}
 
 	}
 
Signature · 1 line
2.30.2
#1 lore raw
Quoted 14 lines · On Sun, 18 Feb 2024 22:43:09 +0300 Maks Mishin <[email protected]> wrote:

Added check for result of rtnl_dump_filter() function for catch errors linked with dump.
Found by RASU JSC.

---
 genl/ctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
genl/ctrl.c +0 -0
index aff922a4..467a2830 100644

genl/ctrl.c static int ctrl_list(int cmd, int argc, char **argv) · line 318

Quoted 7 lines
genl/ctrl.c +3 -1
@@ -313,7 +313,10 @@ static int ctrl_list(int cmd, int argc, char **argv)
 			goto ctrl_done;
 		}
 
-		rtnl_dump_filter(&rth, print_ctrl2, stdout);
+		if (rtnl_dump_filter(&rth, print_ctrl2, stdout) < 0) {
+			fprintf(stderr, "Dump terminated\n");
+			exit(1);

Why does this have to be fatal and call exit()?
Other places in same code just return error.