Skip to content

Commit fce1e9f

Browse files
minimaxwellkuba-moo
authored andcommitted
net: ethtool: phy: Check the req_info.pdn field for GET commands
When processing the netlink GET requests to get PHY info, the req_info.pdn pointer is NULL when no PHY matches the requested parameters, such as when the phy_index is invalid, or there's simply no PHY attached to the interface. Therefore, check the req_info.pdn pointer for NULL instead of dereferencing it. Suggested-by: Eric Dumazet <[email protected]> Reported-by: Eric Dumazet <[email protected]> Closes: https://lore.kernel.org/netdev/CANn89iKRW0WpGAh1tKqY345D8WkYCPm3Y9ym--Si42JZrQAu1g@mail.gmail.com/T/#mfced87d607d18ea32b3b4934dfa18d7b36669285 Fixes: 17194be ("net: ethtool: Introduce a command to list PHYs on an interface") Signed-off-by: Maxime Chevallier <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b2d9544 commit fce1e9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/ethtool/phy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int ethnl_phy_doit(struct sk_buff *skb, struct genl_info *info)
164164
goto err_unlock_rtnl;
165165

166166
/* No PHY, return early */
167-
if (!req_info.pdn->phy)
167+
if (!req_info.pdn)
168168
goto err_unlock_rtnl;
169169

170170
ret = ethnl_phy_reply_size(&req_info.base, info->extack);

0 commit comments

Comments
 (0)