lkml.org 
[lkml]   [2019]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 3/6] staging: fsl-dpaa2/ethsw: Remove netdevice on port probing error
Date
From: Razvan Stefanescu <razvan.stefanescu@nxp.com>

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: Razvan Stefanescu <razvan.stefanescu@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
- none

drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index b2273f840813..9f1617164865 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -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)
--
1.9.1
\
 
 \ /
  Last update: 2019-07-05 16:28    [W:0.161 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site