!15 [sync] PR-14: fix memory free operation after send_ioctl call fails

From: @openeuler-sync-bot 
Reviewed-by: @seuzw 
Signed-off-by: @seuzw
This commit is contained in:
openeuler-ci-bot 2022-09-05 07:58:19 +00:00 committed by Gitee
commit dd4ea92107
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,40 @@
From 8fd02a2f5bd552894ef415b7e5c525be6bc6c3e3 Mon Sep 17 00:00:00 2001
From: Jie Wang <wangjie125@huawei.com>
Date: Mon, 7 Mar 2022 16:08:56 +0800
Subject: [PATCH] ioctl: add the memory free operation after send_ioctl call
fails
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 28ecf69..4f5c234 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

View File

@ -1,12 +1,13 @@
Name: ethtool
Epoch: 2
Version: 5.15
Release: 1
Release: 2
Summary: Settings tool for Ethernet NICs
License: GPLv2
URL: https://www.kernel.org/pub/software/network/ethtool
Source0: https://www.kernel.org/pub/software/network/%{name}/%{name}-%{version}.tar.xz
Patch0: backport-ioctl-add-the-memory-free-operation-after-send_ioctl.patch
BuildRequires: gcc
BuildRequires: libmnl-devel
@ -54,6 +55,12 @@ make check
%{_mandir}/man8/%{name}.8*
%changelog
* Fri Sep 02 2022 gaihuiying <eaglgai@163.com> - 2:5.15-2
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:fix memory free operation after send_ioctl call fails
* Sat Mar 19 2022 xihaochen <xihaochen@h-partners.com> - 2:5.15-1
- Type:requirement
- Id:NA