From: Jie Wang <wangjie125@huawei.com>
To: <mkubecek@suse.cz>, <davem@davemloft.net>, <kuba@kernel.org>,
<wangjie125@huawei.com>
Cc: <netdev@vger.kernel.org>, <huangguangbin2@huawei.com>,
<lipeng321@huawei.com>, <shenjian15@huawei.com>,
<moyufeng@huawei.com>, <linyunsheng@huawei.com>,
<salil.mehta@huawei.com>, <chenhao288@hisilicon.com>
Subject: [PATCH] ethtool: add the memory free operation after send_ioctl call fails
Date: Mon, 7 Mar 2022 16:08:56 +0800 [thread overview]
Message-ID: <20220307080856.39536-1-wangjie125@huawei.com> (raw)
The memory is not freed after send_ioctl fails in function do_gtunable and
do_stunable. This will cause memory leaks.
So this patch adds memory free operation after send_ioctl call fails.
Fixes: b717ed22d984 ("ethtool: add support for get/set ethtool_tunable")
Signed-off-by: Jie Wang <wangjie125@huawei.com>
---
ethtool.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/ethtool.c b/ethtool.c
index 5d718a2..0fbb96b 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5097,6 +5097,7 @@ static int do_stunable(struct cmd_context *ctx)
ret = send_ioctl(ctx, tuna);
if (ret) {
perror(tunable_strings[tuna->id]);
+ free(tuna);
return ret;
}
free(tuna);
@@ -5174,6 +5175,7 @@ static int do_gtunable(struct cmd_context *ctx)
ret = send_ioctl(ctx, tuna);
if (ret) {
fprintf(stderr, "%s: Cannot get tunable\n", ts);
+ free(tuna);
return ret;
}
print_tunable(tuna);
--
2.33.0
reply other threads:[~2022-03-07 8:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307080856.39536-1-wangjie125@huawei.com \
--to=wangjie125@huawei.com \
--cc=chenhao288@hisilicon.com \
--cc=davem@davemloft.net \
--cc=huangguangbin2@huawei.com \
--cc=kuba@kernel.org \
--cc=linyunsheng@huawei.com \
--cc=lipeng321@huawei.com \
--cc=mkubecek@suse.cz \
--cc=moyufeng@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=salil.mehta@huawei.com \
--cc=shenjian15@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).