Commit 2cad5d2e authored by Wong Vee Khee's avatar Wong Vee Khee Committed by Jakub Kicinski

net: pcs: xpcs: fix error handling on failed to allocate memory

Drivers such as sja1105 and stmmac that call xpcs_create() expects an
error returned by the pcs-xpcs module, but this was not the case on
failed to allocate memory.

Fixed this by returning an -ENOMEM instead of a NULL pointer.

Fixes: 3ad1d171 ("net: dsa: sja1105: migrate to xpcs for SGMII")
Signed-off-by: default avatarWong Vee Khee <vee.khee.wong@linux.intel.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20210810085812.1808466-1-vee.khee.wong@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 6922110d
...@@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, ...@@ -1089,7 +1089,7 @@ struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev,
xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL);
if (!xpcs) if (!xpcs)
return NULL; return ERR_PTR(-ENOMEM);
xpcs->mdiodev = mdiodev; xpcs->mdiodev = mdiodev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment