2023-07-03 13:26:48

by Minjie Du

[permalink] [raw]
Subject: [PATCH v1] arch: free dev before return

We fixed a bug where the variable dev
was not freed before return.

Signed-off-by: Minjie Du <[email protected]>
---
arch/xtensa/platforms/iss/network.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c
index 9ac46ab3a..e33f3b37c 100644
--- a/arch/xtensa/platforms/iss/network.c
+++ b/arch/xtensa/platforms/iss/network.c
@@ -540,6 +540,7 @@ static void iss_net_configure(int index, char *init)
rtnl_unlock();
pr_err("%s: error registering net device!\n", dev->name);
platform_device_unregister(&lp->pdev);
+ free_netdev(dev);
return;
}
rtnl_unlock();
--
2.39.0



2023-07-03 14:44:15

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH v1] arch: free dev before return

Hi Minjie,

On Mon, Jul 3, 2023 at 5:33 AM Minjie Du <[email protected]> wrote:
>
> We fixed a bug where the variable dev
> was not freed before return.
>
> Signed-off-by: Minjie Du <[email protected]>
> ---
> arch/xtensa/platforms/iss/network.c | 1 +
> 1 file changed, 1 insertion(+)

Applied to my xtensa tree with the following commit message:

xtensa: ISS: fix etherdev leak in error return path

iss_net_configure frees etherdev in all error return paths except one
where register_netdevice fails. Add missing free_netdev to that path.

--
Thanks.
-- Max

2023-07-03 17:24:12

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH v1] arch: free dev before return

On Mon, Jul 3, 2023 at 7:19 AM Max Filippov <[email protected]> wrote:
> On Mon, Jul 3, 2023 at 5:33 AM Minjie Du <[email protected]> wrote:
> >
> > We fixed a bug where the variable dev
> > was not freed before return.
> >
> > Signed-off-by: Minjie Du <[email protected]>
> > ---
> > arch/xtensa/platforms/iss/network.c | 1 +
> > 1 file changed, 1 insertion(+)
>
> Applied to my xtensa tree with the following commit message:
>
> xtensa: ISS: fix etherdev leak in error return path
>
> iss_net_configure frees etherdev in all error return paths except one
> where register_netdevice fails. Add missing free_netdev to that path.
>

After testing it I realized that in that error return path the etherdev is
freed by the iss_net_pdev_release callback and that this patch
introduces freeing an active timer on that path. I've dropped this patch
and committed another one that adds a comment about what's going
on at that place.

--
Thanks.
-- Max