Patchwork Ethtool: Free memory leak in do_sprivflags()

login
register
mail settings
Submitter Yuval Mintz
Date June 12, 2013, 11:59 a.m.
Message ID <1371038398-15934-1-git-send-email-yuvalmin@broadcom.com>
Download mbox | patch
Permalink /patch/250746/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Yuval Mintz - June 12, 2013, 11:59 a.m.
cmdline is allocated for usage in parse_generic_cmdline(), but is not
released after its final usage.

Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
---
 ethtool.c | 1 +
 1 file changed, 1 insertion(+)
Ben Hutchings - July 1, 2013, 3:59 p.m.
On Wed, 2013-06-12 at 14:59 +0300, Yuval Mintz wrote:
> cmdline is allocated for usage in parse_generic_cmdline(), but is not
> released after its final usage.
> 
> Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>

Applied.

Ben.

> ---
>  ethtool.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ethtool.c b/ethtool.c
> index 8cc10b5..b80494d 100644
> --- a/ethtool.c
> +++ b/ethtool.c
> @@ -3521,6 +3521,7 @@ static int do_sprivflags(struct cmd_context *ctx)
>  		cmdline[i].seen_val = &seen_flags;
>  	}
>  	parse_generic_cmdline(ctx, &any_changed, cmdline, strings->len);
> +	free(cmdline);
>  
>  	flags.cmd = ETHTOOL_GPFLAGS;
>  	if (send_ioctl(ctx, &flags)) {

Patch

diff --git a/ethtool.c b/ethtool.c
index 8cc10b5..b80494d 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3521,6 +3521,7 @@  static int do_sprivflags(struct cmd_context *ctx)
 		cmdline[i].seen_val = &seen_flags;
 	}
 	parse_generic_cmdline(ctx, &any_changed, cmdline, strings->len);
+	free(cmdline);
 
 	flags.cmd = ETHTOOL_GPFLAGS;
 	if (send_ioctl(ctx, &flags)) {