2021-03-29 08:57:11

by Dinghao Liu

[permalink] [raw]
Subject: [PATCH] hostap: Fix memleak in prism2_config

When prism2_hw_config() fails, we just return an error code
without any resource release, which may lead to memleak.

Signed-off-by: Dinghao Liu <[email protected]>
---
drivers/net/wireless/intersil/hostap/hostap_cs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_cs.c b/drivers/net/wireless/intersil/hostap/hostap_cs.c
index ec7db2badc40..7dc16ab50ad6 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_cs.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_cs.c
@@ -536,10 +536,10 @@ static int prism2_config(struct pcmcia_device *link)
sandisk_enable_wireless(dev);

ret = prism2_hw_config(dev, 1);
- if (!ret)
- ret = hostap_hw_ready(dev);
+ if (ret)
+ goto failed;

- return ret;
+ return hostap_hw_ready(dev);;

failed:
kfree(hw_priv);
--
2.17.1


2021-04-07 20:55:11

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] hostap: Fix memleak in prism2_config

Dinghao Liu <[email protected]> writes:

> When prism2_hw_config() fails, we just return an error code
> without any resource release, which may lead to memleak.
>
> Signed-off-by: Dinghao Liu <[email protected]>
> ---
> drivers/net/wireless/intersil/hostap/hostap_cs.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/intersil/hostap/hostap_cs.c b/drivers/net/wireless/intersil/hostap/hostap_cs.c
> index ec7db2badc40..7dc16ab50ad6 100644
> --- a/drivers/net/wireless/intersil/hostap/hostap_cs.c
> +++ b/drivers/net/wireless/intersil/hostap/hostap_cs.c
> @@ -536,10 +536,10 @@ static int prism2_config(struct pcmcia_device *link)
> sandisk_enable_wireless(dev);
>
> ret = prism2_hw_config(dev, 1);
> - if (!ret)
> - ret = hostap_hw_ready(dev);
> + if (ret)
> + goto failed;
>
> - return ret;
> + return hostap_hw_ready(dev);;

Two semicolons.

But I'm not sure about this, can someone provide a Reviewed-by tag?

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2021-04-18 06:17:41

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] hostap: Fix memleak in prism2_config

Dinghao Liu <[email protected]> wrote:

> When prism2_hw_config() fails, we just return an error code
> without any resource release, which may lead to memleak.
>
> Signed-off-by: Dinghao Liu <[email protected]>

Nobody reviewed this, so dropping the patch.

Patch set to Changes Requested.

--
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches