* [PATCH] ethtool: add the memory free operation after send_ioctl call fails
@ 2022-03-07 8:08 Jie Wang
0 siblings, 0 replies; only message in thread
From: Jie Wang @ 2022-03-07 8:08 UTC (permalink / raw)
To: mkubecek, davem, kuba, wangjie125
Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng,
linyunsheng, salil.mehta, chenhao288
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-07 8:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 8:08 [PATCH] ethtool: add the memory free operation after send_ioctl call fails Jie Wang
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).