]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
dcb: fix memory leak
authorAndrea Claudi <aclaudi@redhat.com>
Sat, 1 May 2021 16:39:23 +0000 (18:39 +0200)
committerDavid Ahern <dsahern@kernel.org>
Thu, 6 May 2021 14:48:02 +0000 (14:48 +0000)
main() dinamically allocates dcb, but when dcb_help() is called it
returns without freeing it.

Fix this using a goto, as it is already done in the same function.

Fixes: 67033d1c1c8a ("Add skeleton of a new tool, dcb")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Reviewed-by: Petr Machata <me@pmachata.org>
Signed-off-by: David Ahern <dsahern@kernel.org>
dcb/dcb.c

index 64a9ef02d256be0b435af1dbb4d75c48678a7b38..696f00e4e38c0992a34be197cb81a0de75760620 100644 (file)
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -571,7 +571,8 @@ int main(int argc, char **argv)
                        break;
                case 'h':
                        dcb_help();
-                       return 0;
+                       ret = EXIT_SUCCESS;
+                       goto dcb_free;
                default:
                        fprintf(stderr, "Unknown option.\n");
                        dcb_help();