devlink: Call dl_free in early exit case
Subsystems (2)
PATCH 1/1 devlink: Call dl_free in early exit case
From: Leon Romanovsky <[email protected]>
Prior to parsing command options, the devlink tool allocates memory to store results. In case of early exit (wrong parameters or version check), this memory wasn't freed.
Signed-off-by Leon Romanovsky <[email protected]>
Acked-by Jiri Pirko <[email protected]>
--- devlink/devlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
devlink/devlink.c +4 -2
@@ -2579,7 +2579,8 @@ int main(int argc, char **argv)switch (opt) {case 'V' :printf ("devlink utility, iproute2-ss%s\n" ,SNAPSHOT ); -return EXIT_SUCCESS ; + ret =EXIT_SUCCESS ; + goto dl_free;case 'n' : dl->no_nice_names = true;break ;
@@ -2592,7 +2593,8 @@ int main(int argc, char **argv)default :pr_err ("Unknown option.\n" );help (); -return EXIT_FAILURE ; + ret =EXIT_FAILURE ; + goto dl_free; } }
Stephen Hemminger
AppliedQuoted 8 lines · On Tue, 14 Feb 2017 07:29:38 +0200 Leon Romanovsky <[email protected]> wrote:
From: Leon Romanovsky <[email protected]>
Prior to parsing command options, the devlink tool allocates memory to store results. In case of early exit (wrong parameters or version check), this memory wasn't freed.
Signed-off-by Leon Romanovsky <[email protected]>Acked-by Jiri Pirko <[email protected]>
Applied, thanks.