All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe
@ 2020-08-19 11:50 Dinghao Liu
  2020-08-20  5:29 ` Ajay.Kathat
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-08-19 11:50 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Ajay Singh, Claudiu Beznea, Kalle Valo, David S. Miller,
	Jakub Kicinski, Greg Kroah-Hartman, Eugen Hristev,
	linux-wireless, netdev, linux-kernel

When devm_clk_get() returns -EPROBE_DEFER, sdio_priv
should be freed just like when wilc_cfg80211_init()
fails.

Fixes: 8692b047e86cf ("staging: wilc1000: look for rtc_clk clock")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/net/wireless/microchip/wilc1000/sdio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
index 3ece7b0b0392..351ff909ab1c 100644
--- a/drivers/net/wireless/microchip/wilc1000/sdio.c
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -149,9 +149,10 @@ static int wilc_sdio_probe(struct sdio_func *func,
 	wilc->dev = &func->dev;
 
 	wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
-	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
+	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
+		kfree(sdio_priv);
 		return -EPROBE_DEFER;
-	else if (!IS_ERR(wilc->rtc_clk))
+	} else if (!IS_ERR(wilc->rtc_clk))
 		clk_prepare_enable(wilc->rtc_clk);
 
 	dev_info(&func->dev, "Driver Initializing success\n");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe
  2020-08-19 11:50 [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe Dinghao Liu
@ 2020-08-20  5:29 ` Ajay.Kathat
  2020-08-20  5:42   ` dinghao.liu
  0 siblings, 1 reply; 3+ messages in thread
From: Ajay.Kathat @ 2020-08-20  5:29 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Claudiu.Beznea, kvalo, davem, kuba, gregkh, Eugen.Hristev,
	linux-wireless, netdev, linux-kernel

Thanks for submitting the patch. The code changes looks okay to me.

The driver is now moved out of staging so 'staging' prefix is not
required in subject. For future patches on wilc driver, the 'staging'
prefix can be removed.

For this patch, I am not sure if Kalle can apply as is otherwise please
submit a patch by removing 'staging' from subject so it can be applied
directly.

Regards,
Ajay

On 19/08/20 5:20 pm, Dinghao Liu wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> When devm_clk_get() returns -EPROBE_DEFER, sdio_priv
> should be freed just like when wilc_cfg80211_init()
> fails.
> 
> Fixes: 8692b047e86cf ("staging: wilc1000: look for rtc_clk clock")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/net/wireless/microchip/wilc1000/sdio.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
> index 3ece7b0b0392..351ff909ab1c 100644
> --- a/drivers/net/wireless/microchip/wilc1000/sdio.c
> +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
> @@ -149,9 +149,10 @@ static int wilc_sdio_probe(struct sdio_func *func,
>         wilc->dev = &func->dev;
> 
>         wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
> -       if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER)
> +       if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
> +               kfree(sdio_priv);
>                 return -EPROBE_DEFER;
> -       else if (!IS_ERR(wilc->rtc_clk))
> +       } else if (!IS_ERR(wilc->rtc_clk))
>                 clk_prepare_enable(wilc->rtc_clk);
> 
>         dev_info(&func->dev, "Driver Initializing success\n");
> --
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe
  2020-08-20  5:29 ` Ajay.Kathat
@ 2020-08-20  5:42   ` dinghao.liu
  0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2020-08-20  5:42 UTC (permalink / raw)
  To: Ajay.Kathat
  Cc: kjlu, Claudiu.Beznea, kvalo, davem, kuba, gregkh, Eugen.Hristev,
	linux-wireless, netdev, linux-kernel



Ajay.Kathat@microchip.com写道:
> Thanks for submitting the patch. The code changes looks okay to me.
> 
> The driver is now moved out of staging so 'staging' prefix is not
> required in subject. For future patches on wilc driver, the 'staging'
> prefix can be removed.
> 
> For this patch, I am not sure if Kalle can apply as is otherwise please
> submit a patch by removing 'staging' from subject so it can be applied
> directly.
> 
> Regards,
> Ajay
> 

Thanks for your correction. I'll send a new patch soon.

Regards,
Dinghao

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-20  5:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 11:50 [PATCH] staging: wilc1000: Fix memleak in wilc_sdio_probe Dinghao Liu
2020-08-20  5:29 ` Ajay.Kathat
2020-08-20  5:42   ` dinghao.liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.