net: dsa: sja1105: fix error handling on NULL returned by xpcs_create()
Subsystems (8)
PATCH 1/1 net: dsa: sja1105: fix error handling on NULL returned by xpcs_create()
There is a possibility xpcs_create() returned a NULL and this is not handled properly in the sja1105 driver.
Fixed this by using IS_ERR_ON_NULL() instead of IS_ERR().
--- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/sja1105/sja1105_mdio.c +1 -1
@@ -438,7 +438,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) } xpcs =xpcs_create (mdiodev, priv->phy_mode[port]); -if (IS_ERR (xpcs)) { +if (IS_ERR_OR_NULL (xpcs)) { rc =PTR_ERR (xpcs); goto out_pcs_free; }
Signature · 1 line
2.25.1
Hi VK,
Quoted 28 lines · Wong Vee Khee
There is a possibility
xpcs_create()returned a NULL and this is not handled properly in the sja1105 driver.Fixed this by using
IS_ERR_ON_NULL()instead ofIS_ERR().Fixes 3ad1d171548e ("net: dsa: sja1105: migrate to xpcs for SGMII")Cc Vladimir Olten <[email protected]>Signed-off-by Wong Vee Khee <[email protected]>--- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/sja1105/sja1105_mdio.c +1
-1@@ -438,7 +438,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) } xpcs =xpcs_create (mdiodev, priv->phy_mode[port]); -if (IS_ERR (xpcs)) { +if (IS_ERR_OR_NULL (xpcs)) { rc =PTR_ERR (xpcs); goto out_pcs_free; }Signature · 1 line
2.25.1
I think posting to 'net' is a bit drastic for this patch. I agree it is an issue but it has bothered absolutely nobody so far, and if sending this patch to 'net' means you'll be blocked with your patches until the 'net'->'net-next' merge, I'm not sure it's worth it.
Anyway, I don't think that PTR_ERR(xpcs) does the right thing when IS_NULL(xpcs). So how about you make this change:
-----------------------------[ cut here ]-----------------------------
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +1 -1
@@ -415,7 +415,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus)continue ; xpcs =xpcs_create (mdiodev, mode); -if (IS_ERR_OR_NULL (xpcs)) { +if (IS_ERR (xpcs)) {mdio_device_free (mdiodev);continue ; }
drivers/net/pcs/pcs-xpcs.c +1 -1
@@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, xpcs =kzalloc (sizeof (*xpcs),GFP_KERNEL );if (!xpcs) -return NULL ; +return ERR_PTR (-ENOMEM ); xpcs->mdiodev = mdiodev;
-----------------------------[ cut here ]-----------------------------
Quoted 22 lines · Vladimir Oltean
Hi VK,
Quoted 19 lines · Wong Vee Khee
There is a possibility
xpcs_create()returned a NULL and this is not handled properly in the sja1105 driver.Fixed this by using
IS_ERR_ON_NULL()instead ofIS_ERR().Fixes 3ad1d171548e ("net: dsa: sja1105: migrate to xpcs for SGMII")Cc Vladimir Olten <[email protected]>Signed-off-by Wong Vee Khee <[email protected]>--- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/dsa/sja1105/sja1105_mdio.c +0
-0@@ -438,7 +438,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) }
Quoted 15 lines
Quoted 9 lines
drivers/net/dsa/sja1105/sja1105_mdio.c +1
-1xpcs =xpcs_create (mdiodev, priv->phy_mode[port]); -if (IS_ERR (xpcs)) { +if (IS_ERR_OR_NULL (xpcs)) { rc =PTR_ERR (xpcs); goto out_pcs_free; }Signature · 1 line
2.25.1I think posting to 'net' is a bit drastic for this patch. I agree it is an issue but it has bothered absolutely nobody so far, and if sending this patch to 'net' means you'll be blocked with your patches until the 'net'->'net-next' merge, I'm not sure it's worth it.
Sounds reasonable for me. I will marked V2 to target net-next.
Quoted 31 lines
Anyway, I don't think that
PTR_ERR(xpcs)does the right thing whenIS_NULL(xpcs). So how about you make this change:-----------------------------[ cut here ]-----------------------------
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +1
-1@@ -415,7 +415,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus)continue ; xpcs =xpcs_create (mdiodev, mode); -if (IS_ERR_OR_NULL (xpcs)) { +if (IS_ERR (xpcs)) {mdio_device_free (mdiodev);continue ; }drivers/net/pcs/pcs-xpcs.c +1
-2@@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, xpcs =kzalloc (sizeof (*xpcs),GFP_KERNEL );if (!xpcs) -return NULL ; +return ERR_PTR (-ENOMEM ); xpcs->mdiodev = mdiodev; -----------------------------[ cut here ]-----------------------------