Commit 7dbac0c9 authored by Razvan Stefanescu's avatar Razvan Stefanescu Committed by Greg Kroah-Hartman

staging: fsl-dpaa2/ethsw: Remove netdevice on port probing error

If the ethsw_port_init() call failed, the netdevice remains registered in
the system.

Use labels to ensure that netdevice is unregistered and freed in this case.
Signed-off-by: default avatarRazvan Stefanescu <razvan.stefanescu@nxp.com>
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Link: https://lore.kernel.org/r/1562336836-17119-4-git-send-email-ioana.ciornei@nxp.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b2fdbfa9
......@@ -1460,13 +1460,23 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx)
err = register_netdev(port_netdev);
if (err < 0) {
dev_err(dev, "register_netdev error %d\n", err);
free_netdev(port_netdev);
return err;
goto err_register_netdev;
}
ethsw->ports[port_idx] = port_priv;
return ethsw_port_init(port_priv, port_idx);
err = ethsw_port_init(port_priv, port_idx);
if (err)
goto err_ethsw_port_init;
return 0;
err_ethsw_port_init:
unregister_netdev(port_netdev);
err_register_netdev:
free_netdev(port_netdev);
return err;
}
static int ethsw_probe(struct fsl_mc_device *sw_dev)
......
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