net: ethtool: phy: Check the req_info.pdn field for GET commands
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Tue, 10 Sep 2024 17:46:35 +0000 (19:46 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 11 Sep 2024 23:38:10 +0000 (16:38 -0700)
commitfce1e9f86af13cbd6696ef0c8775990559108f45
tree7fb1937dfeb945f87b565cfaabb5ec52f230658f
parentb2d9544070d052804a12a7859aa212e952b96691
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 <edumazet@google.com>
Reported-by: Eric Dumazet <edumazet@google.com>
Closes: https://lore.kernel.org/netdev/CANn89iKRW0WpGAh1tKqY345D8WkYCPm3Y9ym--Si42JZrQAu1g@mail.gmail.com/T/#mfced87d607d18ea32b3b4934dfa18d7b36669285
Fixes: 17194be4c8e1 ("net: ethtool: Introduce a command to list PHYs on an interface")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240910174636.857352-1-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/phy.c