summaryrefslogtreecommitdiffstats
path: root/net/ethtool
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2021-12-14 07:47:25 -0800
committerDavid S. Miller <davem@davemloft.net>2021-12-15 15:09:24 +0000
commit3bc14ea0d12a57a968038f8e86e9bc2c1668ad9a (patch)
tree4a7268ff8d2517e67471382a53d669a7c63546d8 /net/ethtool
parentf1d9268e061863ead77b07f5a6807d063e28a1c2 (diff)
downloadlinux-3bc14ea0d12a57a968038f8e86e9bc2c1668ad9a.tar.gz
linux-3bc14ea0d12a57a968038f8e86e9bc2c1668ad9a.tar.bz2
linux-3bc14ea0d12a57a968038f8e86e9bc2c1668ad9a.zip
ethtool: always write dev in ethnl_parse_header_dev_get
Commit 0976b888a150 ("ethtool: fix null-ptr-deref on ref tracker") made the write to req_info.dev conditional, but as Eric points out in a different follow up the structure is often allocated on the stack and not kzalloc()'d so seems safer to always write the dev, in case it's garbage on input. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/netlink.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 767fb3f17267..f09c62302a9a 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -141,10 +141,9 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
return -EINVAL;
}
- if (dev) {
- req_info->dev = dev;
+ req_info->dev = dev;
+ if (dev)
netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL);
- }
req_info->flags = flags;
return 0;
}