From: Daniele Palmas dnlplm@gmail.com
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@gmail.com Reviewed-by: Manivannan Sadhasivam mani@kernel.org Reviewed-by: Loic Poulain loic.poulain@linaro.org Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org --- 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; }