All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net, wireless, mwifiex: Fix mem leak in mwifiex_update_curr_bss_params()
@ 2011-11-06 21:58 Jesper Juhl
  2011-11-06 22:24 ` Srivatsa S. Bhat
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2011-11-06 21:58 UTC (permalink / raw)
  To: linux-wireless, netdev, linux-kernel; +Cc: John W. Linville, Bing Zhao

If kmemdup() fails we leak the memory allocated to bss_desc.
This patch fixes the leak.
I also removed the pointless default assignment of 'NULL' to 'bss_desc' 
while I was there anyway.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/net/wireless/mwifiex/scan.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

 note: patch is compile tested only since I don't have the hardware.

diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index dae8dbb..8a3f959 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -1469,7 +1469,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
 			       s32 rssi, const u8 *ie_buf, size_t ie_len,
 			       u16 beacon_period, u16 cap_info_bitmap, u8 band)
 {
-	struct mwifiex_bssdescriptor *bss_desc = NULL;
+	struct mwifiex_bssdescriptor *bss_desc;
 	int ret;
 	unsigned long flags;
 	u8 *beacon_ie;
@@ -1484,6 +1484,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
 
 	beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL);
 	if (!beacon_ie) {
+		kfree(bss_desc);
 		dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
 		return -ENOMEM;
 	}
-- 
1.7.7.2


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] net, wireless, mwifiex: Fix mem leak in mwifiex_update_curr_bss_params()
  2011-11-06 21:58 [PATCH] net, wireless, mwifiex: Fix mem leak in mwifiex_update_curr_bss_params() Jesper Juhl
@ 2011-11-06 22:24 ` Srivatsa S. Bhat
  2011-11-07 19:27   ` Bing Zhao
  0 siblings, 1 reply; 3+ messages in thread
From: Srivatsa S. Bhat @ 2011-11-06 22:24 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-wireless, netdev, linux-kernel, John W. Linville, Bing Zhao

On 11/07/2011 03:28 AM, Jesper Juhl wrote:
> If kmemdup() fails we leak the memory allocated to bss_desc.
> This patch fixes the leak.
> I also removed the pointless default assignment of 'NULL' to 'bss_desc' 
> while I was there anyway.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Looks good to me.
Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Thanks,
Srivatsa S. Bhat

> ---
>  drivers/net/wireless/mwifiex/scan.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
>  note: patch is compile tested only since I don't have the hardware.
> 
> diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
> index dae8dbb..8a3f959 100644
> --- a/drivers/net/wireless/mwifiex/scan.c
> +++ b/drivers/net/wireless/mwifiex/scan.c
> @@ -1469,7 +1469,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
>  			       s32 rssi, const u8 *ie_buf, size_t ie_len,
>  			       u16 beacon_period, u16 cap_info_bitmap, u8 band)
>  {
> -	struct mwifiex_bssdescriptor *bss_desc = NULL;
> +	struct mwifiex_bssdescriptor *bss_desc;
>  	int ret;
>  	unsigned long flags;
>  	u8 *beacon_ie;
> @@ -1484,6 +1484,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
> 
>  	beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL);
>  	if (!beacon_ie) {
> +		kfree(bss_desc);
>  		dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
>  		return -ENOMEM;
>  	}


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

* RE: [PATCH] net, wireless, mwifiex: Fix mem leak in mwifiex_update_curr_bss_params()
  2011-11-06 22:24 ` Srivatsa S. Bhat
@ 2011-11-07 19:27   ` Bing Zhao
  0 siblings, 0 replies; 3+ messages in thread
From: Bing Zhao @ 2011-11-07 19:27 UTC (permalink / raw)
  To: Srivatsa S. Bhat, Jesper Juhl
  Cc: linux-wireless, netdev, linux-kernel, John W. Linville

> On 11/07/2011 03:28 AM, Jesper Juhl wrote:
> > If kmemdup() fails we leak the memory allocated to bss_desc.
> > This patch fixes the leak.
> > I also removed the pointless default assignment of 'NULL' to 'bss_desc'
> > while I was there anyway.
> >
> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Hi Jesper,

Thanks for the patch.

> 
> Looks good to me.
> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>

Hi Srivatsa,

Thanks for your review.

Acked-by: Bing Zhao <bzhao@marvell.com>

Thanks,
Bing

> 
> Thanks,
> Srivatsa S. Bhat
> 
> > ---
> >  drivers/net/wireless/mwifiex/scan.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> >
> >  note: patch is compile tested only since I don't have the hardware.
> >
> > diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
> > index dae8dbb..8a3f959 100644
> > --- a/drivers/net/wireless/mwifiex/scan.c
> > +++ b/drivers/net/wireless/mwifiex/scan.c
> > @@ -1469,7 +1469,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
> >  			       s32 rssi, const u8 *ie_buf, size_t ie_len,
> >  			       u16 beacon_period, u16 cap_info_bitmap, u8 band)
> >  {
> > -	struct mwifiex_bssdescriptor *bss_desc = NULL;
> > +	struct mwifiex_bssdescriptor *bss_desc;
> >  	int ret;
> >  	unsigned long flags;
> >  	u8 *beacon_ie;
> > @@ -1484,6 +1484,7 @@ mwifiex_update_curr_bss_params(struct mwifiex_private *priv, u8 *bssid,
> >
> >  	beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL);
> >  	if (!beacon_ie) {
> > +		kfree(bss_desc);
> >  		dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n");
> >  		return -ENOMEM;
> >  	}

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

end of thread, other threads:[~2011-11-07 19:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-06 21:58 [PATCH] net, wireless, mwifiex: Fix mem leak in mwifiex_update_curr_bss_params() Jesper Juhl
2011-11-06 22:24 ` Srivatsa S. Bhat
2011-11-07 19:27   ` Bing Zhao

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.