DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] staging: wfx: Fix a memory leak in 'wfx_upload_beacon'
@ 2019-11-01 17:21 Christophe JAILLET
  2019-11-02 10:30 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2019-11-01 17:21 UTC (permalink / raw)
  To: jerome.pouiller, gregkh
  Cc: devel, Christophe JAILLET, kernel-janitors, linux-kernel

The current code is a no-op, because all it can do is 'dev_kfree_skb(NULL)'
Revert the test to free skb, if not NULL.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is purely speculative.

The 'if  (...)' could also be removed completely if we refactor the code
and return directly at the beginning of the function.
Or the 'return -ENOMEM' should be 'err = -ENOMEM; goto done;' in order to
avoid a mixup of goto and direct return.
---
 drivers/staging/wfx/sta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 688586e823c0..e14da8dce388 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -906,7 +906,7 @@ static int wfx_upload_beacon(struct wfx_vif *wvif)
 	wfx_fwd_probe_req(wvif, false);
 
 done:
-	if (!skb)
+	if (skb)
 		dev_kfree_skb(skb);
 	return ret;
 }
-- 
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: wfx: Fix a memory leak in 'wfx_upload_beacon'
  2019-11-01 17:21 [PATCH] staging: wfx: Fix a memory leak in 'wfx_upload_beacon' Christophe JAILLET
@ 2019-11-02 10:30 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-11-02 10:30 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: devel, kernel-janitors, linux-kernel

On Fri, Nov 01, 2019 at 06:21:51PM +0100, Christophe JAILLET wrote:
> The current code is a no-op, because all it can do is 'dev_kfree_skb(NULL)'
> Revert the test to free skb, if not NULL.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is purely speculative.
> 
> The 'if  (...)' could also be removed completely if we refactor the code
> and return directly at the beginning of the function.
> Or the 'return -ENOMEM' should be 'err = -ENOMEM; goto done;' in order to
> avoid a mixup of goto and direct return.
> ---
>  drivers/staging/wfx/sta.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
> index 688586e823c0..e14da8dce388 100644
> --- a/drivers/staging/wfx/sta.c
> +++ b/drivers/staging/wfx/sta.c
> @@ -906,7 +906,7 @@ static int wfx_upload_beacon(struct wfx_vif *wvif)
>  	wfx_fwd_probe_req(wvif, false);
>  
>  done:
> -	if (!skb)
> +	if (skb)
>  		dev_kfree_skb(skb);

Just remove the "if" check entirely, as dev_kfree_skb() can handle NULL
being passed to it.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-01 17:21 [PATCH] staging: wfx: Fix a memory leak in 'wfx_upload_beacon' Christophe JAILLET
2019-11-02 10:30 ` Greg KH

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git