[ethtool] 14/20: ethtool: fix leakage of strings resources in do_sprivflags
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Mon Oct 17 04:09:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
benh pushed a commit to branch master
in repository ethtool.
commit ecbd5ea92dd26188b97e7eaa67eed78780188ad4
Author: John W. Linville <linville at tuxdriver.com>
Date: Fri Sep 30 14:57:27 2016 -0400
ethtool: fix leakage of strings resources in do_sprivflags
Coverity issue: 1363124
Fixes: e1ee596326ae ("Add support for querying and setting private flags")
Signed-off-by: John W. Linville <linville at tuxdriver.com>
Reviewed-by: Greg Rose <grose at lightfleet.com>
---
ethtool.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index c89f446..b8de652 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4283,7 +4283,7 @@ static int do_sprivflags(struct cmd_context *ctx)
struct cmdline_info *cmdline;
struct ethtool_value flags;
u32 wanted_flags = 0, seen_flags = 0;
- int any_changed;
+ int any_changed, rc;
unsigned int i;
strings = get_stringset(ctx, ETH_SS_PRIV_FLAGS,
@@ -4295,7 +4295,8 @@ static int do_sprivflags(struct cmd_context *ctx)
}
if (strings->len == 0) {
fprintf(stderr, "No private flags defined\n");
- return 1;
+ rc = 1;
+ goto err;
}
if (strings->len > 32) {
/* ETHTOOL_{G,S}PFLAGS can only cover 32 flags */
@@ -4306,7 +4307,8 @@ static int do_sprivflags(struct cmd_context *ctx)
cmdline = calloc(strings->len, sizeof(*cmdline));
if (!cmdline) {
perror("Cannot parse arguments");
- return 1;
+ rc = 1;
+ goto err;
}
for (i = 0; i < strings->len; i++) {
cmdline[i].name = ((const char *)strings->data +
@@ -4322,17 +4324,22 @@ static int do_sprivflags(struct cmd_context *ctx)
flags.cmd = ETHTOOL_GPFLAGS;
if (send_ioctl(ctx, &flags)) {
perror("Cannot get private flags");
- return 1;
+ rc = 1;
+ goto err;
}
flags.cmd = ETHTOOL_SPFLAGS;
flags.data = (flags.data & ~seen_flags) | wanted_flags;
if (send_ioctl(ctx, &flags)) {
perror("Cannot set private flags");
- return 1;
+ rc = 1;
+ goto err;
}
- return 0;
+ rc = 0;
+err:
+ free(strings);
+ return rc;
}
static int do_tsinfo(struct cmd_context *ctx)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/ethtool.git
More information about the Kernel-svn-changes
mailing list