linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct
@ 2023-01-27 17:14 Colin Foster
  2023-01-27 17:32 ` Florian Fainelli
  2023-01-30  9:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Colin Foster @ 2023-01-27 17:14 UTC (permalink / raw)
  To: linux-kernel, netdev
  Cc: Florian Fainelli, Xiaolei Wang, Paolo Abeni, Jakub Kicinski,
	Eric Dumazet, David S. Miller, Russell King, Heiner Kallweit,
	Andrew Lunn

Commit bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
introduced a link between net devices and phy devices. It fails to check
whether dev is NULL, leading to a NULL dereference error.

Fixes: bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---
 drivers/net/phy/phy_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9ba8f973f26f..a3917c7acbd3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1538,7 +1538,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 	 * another mac interface, so we should create a device link between
 	 * phy dev and mac dev.
 	 */
-	if (phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
+	if (dev && phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
 		phydev->devlink = device_link_add(dev->dev.parent, &phydev->mdio.dev,
 						  DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
 
-- 
2.25.1


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

* Re: [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct
  2023-01-27 17:14 [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct Colin Foster
@ 2023-01-27 17:32 ` Florian Fainelli
  2023-01-30  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2023-01-27 17:32 UTC (permalink / raw)
  To: Colin Foster, linux-kernel, netdev
  Cc: Xiaolei Wang, Paolo Abeni, Jakub Kicinski, Eric Dumazet,
	David S. Miller, Russell King, Heiner Kallweit, Andrew Lunn



On 1/27/2023 9:14 AM, Colin Foster wrote:
> Commit bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
> introduced a link between net devices and phy devices. It fails to check
> whether dev is NULL, leading to a NULL dereference error.
> 
> Fixes: bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct
  2023-01-27 17:14 [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct Colin Foster
  2023-01-27 17:32 ` Florian Fainelli
@ 2023-01-30  9:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-30  9:30 UTC (permalink / raw)
  To: Colin Foster
  Cc: linux-kernel, netdev, f.fainelli, xiaolei.wang, pabeni, kuba,
	edumazet, davem, linux, hkallweit1, andrew

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Fri, 27 Jan 2023 09:14:27 -0800 you wrote:
> Commit bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
> introduced a link between net devices and phy devices. It fails to check
> whether dev is NULL, leading to a NULL dereference error.
> 
> Fixes: bc66fa87d4fd ("net: phy: Add link between phy dev and mac dev")
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> 
> [...]

Here is the summary with links:
  - [v1,net] net: phy: fix null dereference in phy_attach_direct
    https://git.kernel.org/netdev/net/c/73a876022273

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-01-30  9:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 17:14 [PATCH v1 net] net: phy: fix null dereference in phy_attach_direct Colin Foster
2023-01-27 17:32 ` Florian Fainelli
2023-01-30  9:30 ` patchwork-bot+netdevbpf

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).