Skip to content

Commit aed13f2

Browse files
jhovolddavem330
authored andcommitted
net: dsa: lantiq_gswip: fix use-after-free on failed probe
Make sure to disable and deregister the switch on late probe errors to avoid use-after-free when the device-resource-managed switch is freed. Fixes: 14fceff ("net: dsa: Add Lantiq / Intel DSA driver for vrx200") Cc: stable <[email protected]> # 4.20 Cc: Hauke Mehrtens <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Acked-by: Hauke Mehrtens <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5fb1bee commit aed13f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/dsa/lantiq_gswip.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ static int gswip_probe(struct platform_device *pdev)
10991099
dev_err(dev, "wrong CPU port defined, HW only supports port: %i",
11001100
priv->hw_info->cpu_port);
11011101
err = -EINVAL;
1102-
goto mdio_bus;
1102+
goto disable_switch;
11031103
}
11041104

11051105
platform_set_drvdata(pdev, priv);
@@ -1109,6 +1109,9 @@ static int gswip_probe(struct platform_device *pdev)
11091109
(version & GSWIP_VERSION_MOD_MASK) >> GSWIP_VERSION_MOD_SHIFT);
11101110
return 0;
11111111

1112+
disable_switch:
1113+
gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
1114+
dsa_unregister_switch(priv->ds);
11121115
mdio_bus:
11131116
if (mdio_np)
11141117
mdiobus_unregister(priv->ds->slave_mii_bus);

0 commit comments

Comments
 (0)