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; }