[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211130042021.869529-1-mudongliangabcd@gmail.com>
Date: Tue, 30 Nov 2021 12:20:21 +0800
From: Dongliang Mu <mudongliangabcd@...il.com>
To: Ioana Ciornei <ioana.ciornei@....com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Leon Romanovsky <leon@...nel.org>
Cc: Dongliang Mu <mudongliangabcd@...il.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] dpaa2-eth: add error handling code for dpaa2_eth_dl_register
The commit bbb9ae25fc67 ("dpaa2-eth: Register devlink instance at the end
of probe") moves dpaa2_eth_dl_register at the end of dpaa2_eth_probe.
However, dpaa2_eth_dl_register can return errno when memory allocation or
devlink_register fails.
Fix this by adding error handling code for dpaa2_eth_dl_register
Fixes: bbb9ae25fc67 ("dpaa2-eth: Register devlink instance at the end of probe")
Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 6451c8383639..4bb2b838fa50 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4442,7 +4442,7 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
err = dpaa2_eth_dl_alloc(priv);
if (err)
- goto err_dl_register;
+ goto err_dl_alloc;
err = dpaa2_eth_dl_traps_register(priv);
if (err)
@@ -4462,17 +4462,26 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
dpaa2_dbg_add(priv);
#endif
- dpaa2_eth_dl_register(priv);
+ err = dpaa2_eth_dl_register(priv);
+ if (err < 0) {
+ dev_err(dev, "dpaa2_eth_dl_register failed\n");
+ goto err_dl_register;
+ }
dev_info(dev, "Probed interface %s\n", net_dev->name);
return 0;
+err_dl_register:
+#ifdef CONFIG_DEBUG_FS
+ dpaa2_dbg_remove(priv);
+#endif
+ unregister_netdev(net_dev);
err_netdev_reg:
dpaa2_eth_dl_port_del(priv);
err_dl_port_add:
dpaa2_eth_dl_traps_unregister(priv);
err_dl_trap_register:
dpaa2_eth_dl_free(priv);
-err_dl_register:
+err_dl_alloc:
dpaa2_eth_disconnect_mac(priv);
err_connect_mac:
if (priv->do_link_poll)
--
2.25.1
Powered by blists - more mailing lists