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@xxxxxxxxx> --- 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