diff options
author | Jakub Kicinski <kuba@kernel.org> | 2021-12-13 17:39:02 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-12-14 12:35:56 +0000 |
commit | 0976b888a150476ba955ce4765858824c633cfd2 (patch) | |
tree | bdc4ea0553c8470d3340a80a6e98c8ead4aa4760 /net/ethtool | |
parent | a9aa5e3320ae9d322091993e4ed1b7e7651f00a1 (diff) | |
download | linux-stable-0976b888a150476ba955ce4765858824c633cfd2.tar.gz linux-stable-0976b888a150476ba955ce4765858824c633cfd2.tar.bz2 linux-stable-0976b888a150476ba955ce4765858824c633cfd2.zip |
ethtool: fix null-ptr-deref on ref tracker
dev can be a NULL here, not all requests set require_dev.
Fixes: e4b8954074f6 ("netlink: add net device refcount tracker to struct ethnl_req_info")
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.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 23f32a995099..767fb3f17267 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -141,8 +141,10 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info, return -EINVAL; } - req_info->dev = dev; - netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL); + if (dev) { + req_info->dev = dev; + netdev_tracker_alloc(dev, &req_info->dev_tracker, GFP_KERNEL); + } req_info->flags = flags; return 0; } |