diff mbox series

[v1,net] net: phy: fix null dereference in phy_attach_direct

Message ID 20230127171427.265023-1-colin.foster@in-advantage.com (mailing list archive)
State Accepted
Commit 73a876022273cbc9c1db7869a54444ce8b9d085e
Delegated to: Netdev Maintainers
Headers show
Series [v1,net] net: phy: fix null dereference in phy_attach_direct | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 24 this patch: 24
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 22 this patch: 22
netdev/checkpatch warning WARNING: line length of 91 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Colin Foster Jan. 27, 2023, 5:14 p.m. UTC
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(-)

Comments

Florian Fainelli Jan. 27, 2023, 5:32 p.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org Jan. 30, 2023, 9:30 a.m. UTC | #2
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!
diff mbox series

Patch

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