Skip to content

Commit

Permalink
ethtool: fix null-ptr-deref on ref tracker
Browse files Browse the repository at this point in the history
dev can be a NULL here, not all requests set require_dev.

Fixes: e4b8954 ("netlink: add net device refcount tracker to struct ethnl_req_info")
Signed-off-by: Jakub Kicinski <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kuba-moo authored and davem330 committed Dec 14, 2021
1 parent a9aa5e3 commit 0976b88
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ethtool/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0976b88

Please sign in to comment.