diff mbox series

[1/1] drivers: net: mhi: fix error path in mhi_net_newlink

Message ID 20210924092652.3707-1-dnlplm@gmail.com (mailing list archive)
State Superseded
Commit 4526fe74c3c5095cc55931a3a6fb4932f9e06002
Delegated to: Netdev Maintainers
Headers show
Series [1/1] drivers: net: mhi: fix error path in mhi_net_newlink | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Daniele Palmas Sept. 24, 2021, 9:26 a.m. UTC
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>
---
 drivers/net/mhi_net.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Manivannan Sadhasivam Sept. 24, 2021, 9:49 a.m. UTC | #1
On Fri, Sep 24, 2021 at 11:26:52AM +0200, Daniele Palmas wrote:
> 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>

I guess this patch should be backported to stable kernels. So please CC stable
list.

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> ---
>  drivers/net/mhi_net.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
> index d127eb6e9257..aaa628f859fd 100644
> --- a/drivers/net/mhi_net.c
> +++ b/drivers/net/mhi_net.c
> @@ -321,7 +321,7 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
>  	/* 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);
> @@ -331,10 +331,6 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
>  		return err;
>  
>  	return 0;
> -
> -out_err:
> -	free_netdev(ndev);
> -	return err;
>  }
>  
>  static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev)
> -- 
> 2.30.2
>
Loic Poulain Sept. 24, 2021, 9:50 a.m. UTC | #2
On Fri, 24 Sept 2021 at 11:27, Daniele Palmas <dnlplm@gmail.com> wrote:
>
> 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: Loic Poulain <loic.poulain@linaro.org>
Daniele Palmas Sept. 24, 2021, 11:11 a.m. UTC | #3
Hi Mani,

Il giorno ven 24 set 2021 alle ore 11:49 Manivannan Sadhasivam
<mani@kernel.org> ha scritto:
>
> On Fri, Sep 24, 2021 at 11:26:52AM +0200, Daniele Palmas wrote:
> > 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>
>
> I guess this patch should be backported to stable kernels. So please CC stable
> list.

Just v5.14.x seems to be affected by the same issue, but it requires a
slightly different patch: I'll try to take care of that.

Thanks,
Daniele

>
> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
>
> Thanks,
> Mani
>
> > ---
> >  drivers/net/mhi_net.c | 6 +-----
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
> > index d127eb6e9257..aaa628f859fd 100644
> > --- a/drivers/net/mhi_net.c
> > +++ b/drivers/net/mhi_net.c
> > @@ -321,7 +321,7 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
> >       /* 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);
> > @@ -331,10 +331,6 @@ static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
> >               return err;
> >
> >       return 0;
> > -
> > -out_err:
> > -     free_netdev(ndev);
> > -     return err;
> >  }
> >
> >  static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev)
> > --
> > 2.30.2
> >
patchwork-bot+netdevbpf@kernel.org Sept. 24, 2021, 1:30 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Fri, 24 Sep 2021 11:26:52 +0200 you wrote:
> 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>
> ---
>  drivers/net/mhi_net.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)

Here is the summary with links:
  - [1/1] drivers: net: mhi: fix error path in mhi_net_newlink
    https://git.kernel.org/netdev/net/c/4526fe74c3c5

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
index d127eb6e9257..aaa628f859fd 100644
--- a/drivers/net/mhi_net.c
+++ b/drivers/net/mhi_net.c
@@ -321,7 +321,7 @@  static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
 	/* 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);
@@ -331,10 +331,6 @@  static int mhi_net_newlink(struct mhi_device *mhi_dev, struct net_device *ndev)
 		return err;
 
 	return 0;
-
-out_err:
-	free_netdev(ndev);
-	return err;
 }
 
 static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev)