[PATCH 5.14 172/172] drivers: net: mhi: fix error path in mhi_net_newlink
From: Greg Kroah-Hartman
Date: Mon Oct 04 2021 - 09:42:38 EST
From: Daniele Palmas <dnlplm@xxxxxxxxx>
commit 4526fe74c3c5095cc55931a3a6fb4932f9e06002 upstream.
Fix double free_netdev when mhi_prepare_for_transfer fails.
Fixes: 3ffec6a14f24 ("net: Add mhi-net driver")
Signed-off-by: Daniele Palmas <dnlplm@xxxxxxxxx>
Reviewed-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
Reviewed-by: Loic Poulain <loic.poulain@xxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/net/mhi/net.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
--- a/drivers/net/mhi/net.c
+++ b/drivers/net/mhi/net.c
@@ -337,7 +337,7 @@ static int mhi_net_newlink(void *ctxt, s
/* Start MHI channels */
err = mhi_prepare_for_transfer(mhi_dev);
if (err)
- goto out_err;
+ return err;
/* Number of transfer descriptors determines size of the queue */
mhi_netdev->rx_queue_sz = mhi_get_free_desc_count(mhi_dev, DMA_FROM_DEVICE);
@@ -347,7 +347,7 @@ static int mhi_net_newlink(void *ctxt, s
else
err = register_netdev(ndev);
if (err)
- goto out_err;
+ return err;
if (mhi_netdev->proto) {
err = mhi_netdev->proto->init(mhi_netdev);
@@ -359,8 +359,6 @@ static int mhi_net_newlink(void *ctxt, s
out_err_proto:
unregister_netdevice(ndev);
-out_err:
- free_netdev(ndev);
return err;
}