2016-01-12 01:01:57

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] b43: Fix memory leaks in b43_bus_dev_ssb_init and b43_bus_dev_bcma_init

The memory allocated by kzalloc in b43_bus_dev_ssb_init and
b43_bus_dev_bcma_initis not freed.
This patch fixes the bug by adding kfree in b43_ssb_remove,
b43_bcma_remove and error handling code of b43_bcma_probe.

Thanks Michael for his suggestion.

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/net/wireless/b43/main.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index ec013fb..2c9d9c1 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5683,6 +5683,7 @@ static int b43_bcma_probe(struct bcma_device *core)
schedule_work(&wl->firmware_load);

bcma_out:
+ kfree(dev);
return err;

bcma_err_wireless_exit:
@@ -5716,6 +5717,7 @@ static void b43_bcma_remove(struct bcma_device *core)
b43_leds_unregister(wl);

ieee80211_free_hw(wl->hw);
+ kfree(wldev->dev);
}

static struct bcma_driver b43_bcma_driver = {
@@ -5798,6 +5800,7 @@ static void b43_ssb_remove(struct ssb_device *sdev)

b43_leds_unregister(wl);
b43_wireless_exit(dev, wl);
+ kfree(dev);
}

static struct ssb_driver b43_ssb_driver = {
--
1.7.9.5




2016-01-12 05:45:18

by Michael Büsch

[permalink] [raw]
Subject: Re: [PATCH] b43: Fix memory leaks in b43_bus_dev_ssb_init and b43_bus_dev_bcma_init

On Tue, 12 Jan 2016 09:01:04 +0800
Jia-Ju Bai <[email protected]> wrote:

> The memory allocated by kzalloc in b43_bus_dev_ssb_init and
> b43_bus_dev_bcma_initis not freed.
> This patch fixes the bug by adding kfree in b43_ssb_remove,
> b43_bcma_remove and error handling code of b43_bcma_probe.
>
> Thanks Michael for his suggestion.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>
> ---
> drivers/net/wireless/b43/main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
> index ec013fb..2c9d9c1 100644
> --- a/drivers/net/wireless/b43/main.c
> +++ b/drivers/net/wireless/b43/main.c
> @@ -5683,6 +5683,7 @@ static int b43_bcma_probe(struct bcma_device *core)
> schedule_work(&wl->firmware_load);
>
> bcma_out:
> + kfree(dev);
> return err;
>

This is not correct. It will also free dev for the non-error exit.


--
Michael


Attachments:
(No filename) (819.00 B)
OpenPGP digital signature