Thread (3 messages) 3 messages, 3 authors, 2021-12-15

[PATCH net-next] ethtool: always write dev in ethnl_parse_header_dev_get

flat view
STALE1769d

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-12-14 15:47:31
Subsystem: networking [ethtool], networking [general], the rest · Maintainers: Andrew Lunn, Jakub Kicinski, "David S. Miller", Eric Dumazet, Paolo Abeni, Linus Torvalds

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>
---
 net/ethtool/netlink.c | 5 ++---
 1 file 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;
 }
-- 
2.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help