|
|
4f6fcd |
From a4186edd5bcb44d3236852816c21752eb82e5039 Mon Sep 17 00:00:00 2001
|
|
|
4f6fcd |
From: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
|
|
|
4f6fcd |
Date: Thu, 27 Aug 2020 11:50:33 +0200
|
|
|
4f6fcd |
Subject: [PATCH 12/17] ioctl: only memset non-NULL link settings
|
|
|
4f6fcd |
|
|
|
4f6fcd |
In commit bef780467fa ("ioctl: do not pass transceiver value back to
|
|
|
4f6fcd |
kernel") a regression slipped in. If we have a kernel that does not
|
|
|
4f6fcd |
support the ETHTOOL_xLINKSETTINGS API, then the do_ioctl_glinksettings()
|
|
|
4f6fcd |
function will return a NULL pointer.
|
|
|
4f6fcd |
|
|
|
4f6fcd |
Hence before memset'ing the pointer to zero we must first check it is
|
|
|
4f6fcd |
valid, as NULL return is perfectly fine when running on old kernels.
|
|
|
4f6fcd |
|
|
|
4f6fcd |
Fixes: bef780467fa7 ("ioctl: do not pass transceiver value back to kernel")
|
|
|
4f6fcd |
Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com>
|
|
|
4f6fcd |
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
|
|
|
4f6fcd |
(cherry picked from commit cf12872ebe7d8fac2088e7d2cd5e2a0a5f03499d)
|
|
|
4f6fcd |
---
|
|
|
4f6fcd |
ethtool.c | 5 +++--
|
|
|
4f6fcd |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
4f6fcd |
|
|
|
4f6fcd |
diff --git a/ethtool.c b/ethtool.c
|
|
|
4f6fcd |
index e32a93b41088..606af3e6b48f 100644
|
|
|
4f6fcd |
--- a/ethtool.c
|
|
|
4f6fcd |
+++ b/ethtool.c
|
|
|
4f6fcd |
@@ -3048,10 +3048,11 @@ static int do_sset(struct cmd_context *ctx)
|
|
|
4f6fcd |
struct ethtool_link_usettings *link_usettings;
|
|
|
4f6fcd |
|
|
|
4f6fcd |
link_usettings = do_ioctl_glinksettings(ctx);
|
|
|
4f6fcd |
- memset(&link_usettings->deprecated, 0,
|
|
|
4f6fcd |
- sizeof(link_usettings->deprecated));
|
|
|
4f6fcd |
if (link_usettings == NULL)
|
|
|
4f6fcd |
link_usettings = do_ioctl_gset(ctx);
|
|
|
4f6fcd |
+ else
|
|
|
4f6fcd |
+ memset(&link_usettings->deprecated, 0,
|
|
|
4f6fcd |
+ sizeof(link_usettings->deprecated));
|
|
|
4f6fcd |
if (link_usettings == NULL) {
|
|
|
4f6fcd |
perror("Cannot get current device settings");
|
|
|
4f6fcd |
err = -1;
|
|
|
4f6fcd |
--
|
|
|
4f6fcd |
2.26.2
|
|
|
4f6fcd |
|