[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211004114601.13870-1-dnlplm@gmail.com>
Date: Mon, 4 Oct 2021 13:46:01 +0200
From: Daniele Palmas <dnlplm@...il.com>
To: Loic Poulain <loic.poulain@...aro.org>,
Manivannan Sadhasivam <mani@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Sergey Ryazanov <ryazanov.s.a@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: netdev@...r.kernel.org, stable@...r.kernel.org,
Daniele Palmas <dnlplm@...il.com>
Subject: [PATCH 1/1] drivers: net: mhi: fix error path in mhi_net_newlink
Fix double free_netdev when mhi_prepare_for_transfer fails.
This is a back-port of upstream:
commit 4526fe74c3c509 ("drivers: net: mhi: fix error path in mhi_net_newlink")
Fixes: 13adac032982 ("net: mhi_net: Register wwan_ops for link creation")
Signed-off-by: Daniele Palmas <dnlplm@...il.com>
---
Hello Greg,
if maintainers ack, this should go just to 5.14 branch.
Thanks,
Daniele
---
drivers/net/mhi/net.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/mhi/net.c b/drivers/net/mhi/net.c
index e60e38c1f09d..5e49f7a919b6 100644
--- a/drivers/net/mhi/net.c
+++ b/drivers/net/mhi/net.c
@@ -337,7 +337,7 @@ static int mhi_net_newlink(void *ctxt, struct net_device *ndev, u32 if_id,
/* 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, struct net_device *ndev, u32 if_id,
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, struct net_device *ndev, u32 if_id,
out_err_proto:
unregister_netdevice(ndev);
-out_err:
- free_netdev(ndev);
return err;
}
--
2.30.2
Powered by blists - more mailing lists