net: arc_emac: Fix memleak in arc_mdio_probe
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Sun, 23 Aug 2020 08:56:47 +0000 (16:56 +0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 25 Aug 2020 00:59:44 +0000 (17:59 -0700)
When devm_gpiod_get_optional() fails, bus should be
freed just like when of_mdiobus_register() fails.

Fixes: 1bddd96cba03d ("net: arc_emac: support the phy reset for emac driver")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/arc/emac_mdio.c

index 0187dbf3b87dfcdaa2dc1bf39f37a4d4bf47c7a6..54cdafdd067db3d19ac81dd7132e09a13fe86445 100644 (file)
@@ -153,6 +153,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
        if (IS_ERR(data->reset_gpio)) {
                error = PTR_ERR(data->reset_gpio);
                dev_err(priv->dev, "Failed to request gpio: %d\n", error);
+               mdiobus_free(bus);
                return error;
        }