aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans-Christian Noren Egtvedt <hegtvedt@cisco.com>2020-08-27 11:50:33 +0200
committerMichal Kubecek <mkubecek@suse.cz>2020-08-27 12:14:39 +0200
commitcf12872ebe7d8fac2088e7d2cd5e2a0a5f03499d (patch)
tree7e94beed4526d9d4ea534402c8f9721a1c93d984
parenta9a6fc7afda9b04ec088b81ad5fd1164c2bb8830 (diff)
downloadethtool-cf12872ebe7d8fac2088e7d2cd5e2a0a5f03499d.tar.gz
ioctl: only memset non-NULL link settings
In commit bef780467fa ("ioctl: do not pass transceiver value back to kernel") a regression slipped in. If we have a kernel that does not support the ETHTOOL_xLINKSETTINGS API, then the do_ioctl_glinksettings() function will return a NULL pointer. Hence before memset'ing the pointer to zero we must first check it is valid, as NULL return is perfectly fine when running on old kernels. Fixes: bef780467fa7 ("ioctl: do not pass transceiver value back to kernel") Signed-off-by: Hans-Christian Noren Egtvedt <hegtvedt@cisco.com> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
-rw-r--r--ethtool.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ethtool.c b/ethtool.c
index e32a93b..606af3e 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -3048,10 +3048,11 @@ static int do_sset(struct cmd_context *ctx)
struct ethtool_link_usettings *link_usettings;
link_usettings = do_ioctl_glinksettings(ctx);
- memset(&link_usettings->deprecated, 0,
- sizeof(link_usettings->deprecated));
if (link_usettings == NULL)
link_usettings = do_ioctl_gset(ctx);
+ else
+ memset(&link_usettings->deprecated, 0,
+ sizeof(link_usettings->deprecated));
if (link_usettings == NULL) {
perror("Cannot get current device settings");
err = -1;