Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1337311 > unrolled thread

[PATCH] b43: fix memory leak

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2016-02-18 13:40 +0100
Last post2016-02-19 16:10 +0100
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] b43: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-02-18 13:40 +0100
    Re: [PATCH] b43: fix memory leak Rafał Miłecki <zajec5@gmail.com> - 2016-02-18 14:50 +0100
    Re: [PATCH] b43: fix memory leak Michael Büsch <m@bues.ch> - 2016-02-18 17:40 +0100
      Re: [PATCH] b43: fix memory leak Kalle Valo <kvalo@codeaurora.org> - 2016-02-19 08:50 +0100
        Re: [PATCH] b43: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2016-02-19 16:10 +0100

#1337311 — [PATCH] b43: fix memory leak

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2016-02-18 13:40 +0100
Subject[PATCH] b43: fix memory leak
Message-ID<r3w2d-5u1-3@gated-at.bofh.it>
From: Sudip Mukherjee <sudip@vectorindia.org>

On error we jumped to the label bcma_out and returned the error code but
we missed freeing dev.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/net/wireless/broadcom/b43/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/broadcom/b43/main.c b/drivers/net/wireless/broadcom/b43/main.c
index c279211..78f670a 100644
--- a/drivers/net/wireless/broadcom/b43/main.c
+++ b/drivers/net/wireless/broadcom/b43/main.c
@@ -5671,6 +5671,7 @@ static int b43_bcma_probe(struct bcma_device *core)
 	wl = b43_wireless_init(dev);
 	if (IS_ERR(wl)) {
 		err = PTR_ERR(wl);
+		kfree(dev);
 		goto bcma_out;
 	}
 
-- 
1.9.1

[toc] | [next] | [standalone]


#1337364

FromRafał Miłecki <zajec5@gmail.com>
Date2016-02-18 14:50 +0100
Message-ID<r3x7Y-6f7-9@gated-at.bofh.it>
In reply to#1337311
On 18 February 2016 at 13:34, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> From: Sudip Mukherjee <sudip@vectorindia.org>
>
> On error we jumped to the label bcma_out and returned the error code but
> we missed freeing dev.

What if b43_one_core_attach fails? Won't we miss kfree then as well?
Shouldn't you simply improve error path and maybe use an additional
label? Also may we be missing a proper free in b43_bcma_remove as
well?

Your patch subject could also be a bit more descriptive (e.g. what
memory leak exactly is it).

[toc] | [prev] | [next] | [standalone]


#1337511

FromMichael Büsch <m@bues.ch>
Date2016-02-18 17:40 +0100
Message-ID<r3zMu-8l2-21@gated-at.bofh.it>
In reply to#1337311

[Multipart message — attachments visible in raw view] — view raw

On Thu, 18 Feb 2016 18:04:36 +0530
Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:

> From: Sudip Mukherjee <sudip@vectorindia.org>
> 
> On error we jumped to the label bcma_out and returned the error code but
> we missed freeing dev.
> 
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/net/wireless/broadcom/b43/main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/wireless/broadcom/b43/main.c b/drivers/net/wireless/broadcom/b43/main.c
> index c279211..78f670a 100644
> --- a/drivers/net/wireless/broadcom/b43/main.c
> +++ b/drivers/net/wireless/broadcom/b43/main.c
> @@ -5671,6 +5671,7 @@ static int b43_bcma_probe(struct bcma_device *core)
>  	wl = b43_wireless_init(dev);
>  	if (IS_ERR(wl)) {
>  		err = PTR_ERR(wl);
> +		kfree(dev);
>  		goto bcma_out;
>  	}
>  

We recently had a patch that fixes this, among more leaks. Subject:
[PATCH v2 resend] b43: Fix memory leaks in b43_bus_dev_ssb_init and
b43_bus_dev_bcma_init

Please test that patch instead, so we can finally apply it.

It needs to be tested on both ssb and bcma. Come on. This isn't too
hard. :) Please somebody with any hardware test it. (I currently don't
have any b43 hardware)

-- 
Michael

[toc] | [prev] | [next] | [standalone]


#1337945

FromKalle Valo <kvalo@codeaurora.org>
Date2016-02-19 08:50 +0100
Message-ID<r3NZ7-1H6-1@gated-at.bofh.it>
In reply to#1337511
Michael Büsch <m@bues.ch> writes:

> On Thu, 18 Feb 2016 18:04:36 +0530
> Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>
>> From: Sudip Mukherjee <sudip@vectorindia.org>
>> 
>> On error we jumped to the label bcma_out and returned the error code but
>> we missed freeing dev.
>> 
>> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>> ---
>>  drivers/net/wireless/broadcom/b43/main.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/net/wireless/broadcom/b43/main.c b/drivers/net/wireless/broadcom/b43/main.c
>> index c279211..78f670a 100644
>> --- a/drivers/net/wireless/broadcom/b43/main.c
>> +++ b/drivers/net/wireless/broadcom/b43/main.c
>> @@ -5671,6 +5671,7 @@ static int b43_bcma_probe(struct bcma_device *core)
>>  	wl = b43_wireless_init(dev);
>>  	if (IS_ERR(wl)) {
>>  		err = PTR_ERR(wl);
>> +		kfree(dev);
>>  		goto bcma_out;
>>  	}
>>  
>
> We recently had a patch that fixes this, among more leaks. Subject:
> [PATCH v2 resend] b43: Fix memory leaks in b43_bus_dev_ssb_init and
> b43_bus_dev_bcma_init
>
> Please test that patch instead, so we can finally apply it.
>
> It needs to be tested on both ssb and bcma. Come on. This isn't too
> hard. :) Please somebody with any hardware test it. (I currently don't
> have any b43 hardware)

And the patch can be downloaded from patchwork:

https://patchwork.kernel.org/patch/8049041/

-- 
Kalle Valo

[toc] | [prev] | [next] | [standalone]


#1338270

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2016-02-19 16:10 +0100
Message-ID<r3UQV-6RV-11@gated-at.bofh.it>
In reply to#1337945
On Friday 19 February 2016 01:14 PM, Kalle Valo wrote:
> Michael Büsch <m@bues.ch> writes:
>
>> On Thu, 18 Feb 2016 18:04:36 +0530
>> Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:
>>
>>> From: Sudip Mukherjee <sudip@vectorindia.org>
>>>
>>> On error we jumped to the label bcma_out and returned the error code but
>>> we missed freeing dev.
>>>
>>> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>>> ---
>>>   drivers/net/wireless/broadcom/b43/main.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/net/wireless/broadcom/b43/main.c b/drivers/net/wireless/broadcom/b43/main.c
>>> index c279211..78f670a 100644
>>> --- a/drivers/net/wireless/broadcom/b43/main.c
>>> +++ b/drivers/net/wireless/broadcom/b43/main.c
>>> @@ -5671,6 +5671,7 @@ static int b43_bcma_probe(struct bcma_device *core)
>>>   	wl = b43_wireless_init(dev);
>>>   	if (IS_ERR(wl)) {
>>>   		err = PTR_ERR(wl);
>>> +		kfree(dev);
>>>   		goto bcma_out;
>>>   	}
>>>
>>
>> We recently had a patch that fixes this, among more leaks. Subject:
>> [PATCH v2 resend] b43: Fix memory leaks in b43_bus_dev_ssb_init and
>> b43_bus_dev_bcma_init
>>
>> Please test that patch instead, so we can finally apply it.
>>
>> It needs to be tested on both ssb and bcma. Come on. This isn't too
>> hard. :) Please somebody with any hardware test it. (I currently don't
>> have any b43 hardware)
>
> And the patch can be downloaded from patchwork:
>
> https://patchwork.kernel.org/patch/8049041/

I have an old laptop running on 800Mhz CPU. It has "Broadcom BCM4311 
[14e4:4311] (rev 01)".
I will try to test it on this weekend.

regards
sudip

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web