diff mbox series

ctrl: Add check for result rtnl_dump_filter()

Message ID 20240218194309.31482-1-maks.mishinFZ@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Stephen Hemminger
Headers show
Series ctrl: Add check for result rtnl_dump_filter() | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Maks Mishin Feb. 18, 2024, 7:43 p.m. UTC
Added check for result of rtnl_dump_filter() function
for catch errors linked with dump.
Found by RASU JSC.

Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
 genl/ctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Feb. 19, 2024, 5:51 p.m. UTC | #1
On Sun, 18 Feb 2024 22:43:09 +0300
Maks Mishin <maks.mishinfz@gmail.com> wrote:

> Added check for result of rtnl_dump_filter() function
> for catch errors linked with dump.
> Found by RASU JSC.
> 
> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
>  genl/ctrl.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/genl/ctrl.c b/genl/ctrl.c
> index aff922a4..467a2830 100644
> --- a/genl/ctrl.c
> +++ b/genl/ctrl.c
> @@ -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.
diff mbox series

Patch

diff --git a/genl/ctrl.c b/genl/ctrl.c
index aff922a4..467a2830 100644
--- a/genl/ctrl.c
+++ b/genl/ctrl.c
@@ -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);
+		}
 
 	}