diff mbox series

[iproute2,2/2] dcb: fix memory leak

Message ID 0d19dbb485632ecfbbc09e04e8151f7157e6960b.1619886883.git.aclaudi@redhat.com (mailing list archive)
State Accepted
Delegated to: David Ahern
Headers show
Series dcb: some misc fixes | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Andrea Claudi May 1, 2021, 4:39 p.m. UTC
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>
---
 dcb/dcb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Petr Machata May 5, 2021, 8:33 a.m. UTC | #1
Andrea Claudi <aclaudi@redhat.com> writes:

> 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>

Thanks!

Reviewed-by: Petr Machata <me@pmachata.org>
diff mbox series

Patch

diff --git a/dcb/dcb.c b/dcb/dcb.c
index 64a9ef02..696f00e4 100644
--- 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();