netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: Fix potential null pointer access
@ 2023-11-20  9:32 Lukas Funke
  2023-11-20  9:51 ` Russell King (Oracle)
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Funke @ 2023-11-20  9:32 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Lukas Funke, netdev, linux-kernel

From: Lukas Funke <lukas.funke@weidmueller.com>

When there is no driver associated with the phydev, there will be a
nullptr access. The commit checks if the phydev driver is set before
access.

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1135e63a4a76..4de83e3cab77 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -136,7 +136,7 @@ EXPORT_SYMBOL(phy_print_status);
 static int phy_config_interrupt(struct phy_device *phydev, bool interrupts)
 {
 	phydev->interrupts = interrupts ? 1 : 0;
-	if (phydev->drv->config_intr)
+	if (phydev->drv && phydev->drv->config_intr)
 		return phydev->drv->config_intr(phydev);
 
 	return 0;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-20 13:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-20  9:32 [PATCH] net: phy: Fix potential null pointer access Lukas Funke
2023-11-20  9:51 ` Russell King (Oracle)
2023-11-20 12:38   ` Lukas Funke
2023-11-20 13:42     ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).