Skip to contentSkip to conversation

net: phy: nxp-c45-tja11xx: Fix incorrect usage of devm_kzalloc

PATCH In review Ye Li 2 participants 2 messages Apr 28 – Apr 29

Subsystems (3)
lore
Share & tools
lore

Ye Li

author
#0 lore raw

PATCH 1/1 net: phy: nxp-c45-tja11xx: Fix incorrect usage of devm_kzalloc

devm_kzalloc needs to pass udevice for first parameter, this phy driver wrongly pass the priv in phy_device. And because the dev in phy_device is only valid after phy_connect, in probe phase this dev is NULL, so we can't use devm_kzalloc, replace it with kzalloc.

---
 drivers/net/phy/nxp-c45-tja11xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/nxp-c45-tja11xx.c +1 -1
index a1e4c3d053b..9814ac498ed 100644
@@ -343,7 +343,7 @@ static int nxp_c45_probe(struct phy_device *phydev)
 {
 	struct nxp_c45_phy *priv;
 
-	priv = devm_kzalloc(phydev->priv, sizeof(*priv), GFP_KERNEL);
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
Signature · 1 line
2.37.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ye Li

devm_kzalloc needs to pass udevice for first parameter, this phy driver wrongly pass the priv in phy_device. And because the dev in phy_device is only valid after phy_connect, in probe phase this dev is NULL, so we can't use devm_kzalloc, replace it with kzalloc.