diff mbox series

[net-next,v1,3/3] net: dsa: ksz: ksz8863_smi_probe: set proper return value for ksz_switch_alloc()

Message ID 20210429110833.2181-3-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Commit d4eecfb28b963493a8701f271789ff04e92ae205
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1,1/3] net: dsa: ksz: ksz8863_smi_probe: fix possible NULL pointer dereference | expand

Checks

Context Check Description
netdev/cover_letter warning Series does not have a cover letter
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers fail 1 blamed authors not CCed: linux@rempel-privat.de; 1 maintainers not CCed: linux@rempel-privat.de
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Oleksij Rempel April 29, 2021, 11:08 a.m. UTC
ksz_switch_alloc() will return NULL only if allocation is failed. So,
the proper return value is -ENOMEM.

Fixes: 60a364760002 ("net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8863_smi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn April 29, 2021, 12:14 p.m. UTC | #1
On Thu, Apr 29, 2021 at 01:08:33PM +0200, Oleksij Rempel wrote:
> ksz_switch_alloc() will return NULL only if allocation is failed. So,
> the proper return value is -ENOMEM.
> 
> Fixes: 60a364760002 ("net: dsa: microchip: Add Microchip KSZ8863 SMI based driver support")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8863_smi.c b/drivers/net/dsa/microchip/ksz8863_smi.c
index 9fb38e99001a..11293485138c 100644
--- a/drivers/net/dsa/microchip/ksz8863_smi.c
+++ b/drivers/net/dsa/microchip/ksz8863_smi.c
@@ -154,7 +154,7 @@  static int ksz8863_smi_probe(struct mdio_device *mdiodev)
 
 	dev = ksz_switch_alloc(&mdiodev->dev, ksz8);
 	if (!dev)
-		return -EINVAL;
+		return -ENOMEM;
 
 	for (i = 0; i < ARRAY_SIZE(ksz8863_regmap_config); i++) {
 		rc = ksz8863_regmap_config[i];