]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ethtool: fix null-ptr-deref on ref tracker
authorJakub Kicinski <kuba@kernel.org>
Tue, 14 Dec 2021 01:39:02 +0000 (17:39 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Dec 2021 12:35:56 +0000 (12:35 +0000)
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>
net/ethtool/netlink.c

index 23f32a995099ab420d25651d85c192210b76442f..767fb3f17267602ef25ab678a8910072c266d898 100644 (file)
@@ -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;
 }