netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
       [not found] <CGME20201028015033epcas1p4f3d9b38b037ff6d4432e1a2866544e38@epcas1p4.samsung.com>
@ 2020-10-28  1:52 ` Seung-Woo Kim
  2020-11-02 17:15   ` Kalle Valo
  2020-11-07 16:19   ` [v2] " Kalle Valo
  0 siblings, 2 replies; 6+ messages in thread
From: Seung-Woo Kim @ 2020-10-28  1:52 UTC (permalink / raw)
  To: arend.vanspriel, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, kvalo, davem, kuba, linux-wireless,
	brcm80211-dev-list.pdl, brcm80211-dev-list
  Cc: smoch, sandals, rafal, digetx, double.lo, amsr, stanley.hsu,
	saravanan.shanmugham, jean-philippe, frank.kao, netdev,
	sw0312.kim, jh80.chung

There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
by adding missed brcmf_free().

Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
Fixes: commit 450914c39f88 ("brcmfmac: split brcmf_attach() and brcmf_detach() functions")
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
Change from v1 [1]
- add Fixes tag for the commit creating brcmf_alloc/free and unpaired path
- add Reviewd-by tag from Arend

[1] https://lore.kernel.org/linux-wireless/1603795630-14638-1-git-send-email-sw0312.kim@samsung.com/
---
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    |    6 ++++--
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c    |    1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 39381cb..d8db0db 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -1936,16 +1936,18 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
 	fwreq = brcmf_pcie_prepare_fw_request(devinfo);
 	if (!fwreq) {
 		ret = -ENOMEM;
-		goto fail_bus;
+		goto fail_brcmf;
 	}
 
 	ret = brcmf_fw_get_firmwares(bus->dev, fwreq, brcmf_pcie_setup);
 	if (ret < 0) {
 		kfree(fwreq);
-		goto fail_bus;
+		goto fail_brcmf;
 	}
 	return 0;
 
+fail_brcmf:
+	brcmf_free(&devinfo->pdev->dev);
 fail_bus:
 	kfree(bus->msgbuf);
 	kfree(bus);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 99987a7..59c2b2b 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -4541,6 +4541,7 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
 		brcmf_sdiod_intr_unregister(bus->sdiodev);
 
 		brcmf_detach(bus->sdiodev->dev);
+		brcmf_free(bus->sdiodev->dev);
 
 		cancel_work_sync(&bus->datawork);
 		if (bus->brcmf_wq)
-- 
1.7.4.1


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

* Re: [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
  2020-10-28  1:52 ` [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free} Seung-Woo Kim
@ 2020-11-02 17:15   ` Kalle Valo
  2020-11-02 17:40     ` Arend Van Spriel
  2020-11-07 16:19   ` [v2] " Kalle Valo
  1 sibling, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2020-11-02 17:15 UTC (permalink / raw)
  To: Seung-Woo Kim
  Cc: arend.vanspriel, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, kuba, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list, smoch, sandals, rafal, digetx, double.lo,
	amsr, stanley.hsu, saravanan.shanmugham, jean-philippe,
	frank.kao, netdev, jh80.chung

Seung-Woo Kim <sw0312.kim@samsung.com> writes:

> There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
> by adding missed brcmf_free().
>
> Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
> Fixes: commit 450914c39f88 ("brcmfmac: split brcmf_attach() and brcmf_detach() functions")

This should be:

Fixes: 450914c39f88 ("brcmfmac: split brcmf_attach() and brcmf_detach() functions")

But I can fix that, no need to resend because of this.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
  2020-11-02 17:15   ` Kalle Valo
@ 2020-11-02 17:40     ` Arend Van Spriel
  2020-11-02 17:46       ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Arend Van Spriel @ 2020-11-02 17:40 UTC (permalink / raw)
  To: Kalle Valo, Seung-Woo Kim
  Cc: franky.lin, hante.meuleman, chi-hsien.lin, wright.feng, davem,
	kuba, linux-wireless, brcm80211-dev-list.pdl, brcm80211-dev-list,
	smoch, sandals, rafal, digetx, double.lo, amsr, stanley.hsu,
	saravanan.shanmugham, jean-philippe, frank.kao, netdev,
	jh80.chung

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

On November 2, 2020 6:15:32 PM Kalle Valo <kvalo@codeaurora.org> wrote:

> Seung-Woo Kim <sw0312.kim@samsung.com> writes:
>
>> There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
>> by adding missed brcmf_free().
>>
>> Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
>> Fixes: commit 450914c39f88 ("brcmfmac: split brcmf_attach() and 
>> brcmf_detach() functions")
>
> This should be:
>
> Fixes: 450914c39f88 ("brcmfmac: split brcmf_attach() and brcmf_detach() 
> functions")
>
> But I can fix that, no need to resend because of this.

Hi Kalle,

But this is not the commit that needs fixing as I mentioned before. Instead 
it should be a1f5aac1765af ("brcmfmac: don't realloc wiphy during PCIe 
reset") which introduced the actual memory leak.

Regards,
Arend

> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches




[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4176 bytes --]

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

* Re: [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
  2020-11-02 17:40     ` Arend Van Spriel
@ 2020-11-02 17:46       ` Kalle Valo
  2020-11-02 18:13         ` Arend Van Spriel
  0 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2020-11-02 17:46 UTC (permalink / raw)
  To: Arend Van Spriel
  Cc: Seung-Woo Kim, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, kuba, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list, smoch, sandals, rafal, digetx, double.lo,
	amsr, stanley.hsu, saravanan.shanmugham, jean-philippe,
	frank.kao, netdev, jh80.chung

Arend Van Spriel <arend.vanspriel@broadcom.com> writes:

> On November 2, 2020 6:15:32 PM Kalle Valo <kvalo@codeaurora.org> wrote:
>
>> Seung-Woo Kim <sw0312.kim@samsung.com> writes:
>>
>>> There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
>>> by adding missed brcmf_free().
>>>
>>> Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
>>> Fixes: commit 450914c39f88 ("brcmfmac: split brcmf_attach() and
>>> brcmf_detach() functions")
>>
>> This should be:
>>
>> Fixes: 450914c39f88 ("brcmfmac: split brcmf_attach() and
>> brcmf_detach() functions")
>>
>> But I can fix that, no need to resend because of this.
>
> Hi Kalle,
>
> But this is not the commit that needs fixing as I mentioned before.
> Instead it should be a1f5aac1765af ("brcmfmac: don't realloc wiphy
> during PCIe reset") which introduced the actual memory leak.

I'll then change it to:

Fixes: a1f5aac1765a ("brcmfmac: don't realloc wiphy during PCIe reset")

Is that ok?

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
  2020-11-02 17:46       ` Kalle Valo
@ 2020-11-02 18:13         ` Arend Van Spriel
  0 siblings, 0 replies; 6+ messages in thread
From: Arend Van Spriel @ 2020-11-02 18:13 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Seung-Woo Kim, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, kuba, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list, smoch, sandals, rafal, digetx, double.lo,
	amsr, stanley.hsu, saravanan.shanmugham, jean-philippe,
	frank.kao, netdev, jh80.chung

[-- Attachment #1: Type: text/plain, Size: 1098 bytes --]

On November 2, 2020 6:46:12 PM Kalle Valo <kvalo@codeaurora.org> wrote:

> Arend Van Spriel <arend.vanspriel@broadcom.com> writes:
>
>> On November 2, 2020 6:15:32 PM Kalle Valo <kvalo@codeaurora.org> wrote:
>>
>>> Seung-Woo Kim <sw0312.kim@samsung.com> writes:
>>>
>>>> There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
>>>> by adding missed brcmf_free().
>>>>
>>>> Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
>>>> Fixes: commit 450914c39f88 ("brcmfmac: split brcmf_attach() and
>>>> brcmf_detach() functions")
>>>
>>> This should be:
>>>
>>> Fixes: 450914c39f88 ("brcmfmac: split brcmf_attach() and
>>> brcmf_detach() functions")
>>>
>>> But I can fix that, no need to resend because of this.
>>
>> Hi Kalle,
>>
>> But this is not the commit that needs fixing as I mentioned before.
>> Instead it should be a1f5aac1765af ("brcmfmac: don't realloc wiphy
>> during PCIe reset") which introduced the actual memory leak.
>
> I'll then change it to:
>
> Fixes: a1f5aac1765a ("brcmfmac: don't realloc wiphy during PCIe reset")
>
> Is that ok?

It is for me ;-)

Regards,
Arend



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4176 bytes --]

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

* Re: [v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}
  2020-10-28  1:52 ` [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free} Seung-Woo Kim
  2020-11-02 17:15   ` Kalle Valo
@ 2020-11-07 16:19   ` Kalle Valo
  1 sibling, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2020-11-07 16:19 UTC (permalink / raw)
  To: Seung-Woo Kim
  Cc: arend.vanspriel, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, davem, kuba, linux-wireless, brcm80211-dev-list.pdl,
	brcm80211-dev-list, smoch, sandals, rafal, digetx, double.lo,
	amsr, stanley.hsu, saravanan.shanmugham, jean-philippe,
	frank.kao, netdev, sw0312.kim, jh80.chung

Seung-Woo Kim <sw0312.kim@samsung.com> wrote:

> There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
> by adding missed brcmf_free().
> 
> Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
> Fixes: a1f5aac1765a ("brcmfmac: don't realloc wiphy during PCIe reset")
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Patch applied to wireless-drivers-next.git, thanks.

9db946284e07 brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/1603849967-22817-1-git-send-email-sw0312.kim@samsung.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20201028015033epcas1p4f3d9b38b037ff6d4432e1a2866544e38@epcas1p4.samsung.com>
2020-10-28  1:52 ` [PATCH v2] brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free} Seung-Woo Kim
2020-11-02 17:15   ` Kalle Valo
2020-11-02 17:40     ` Arend Van Spriel
2020-11-02 17:46       ` Kalle Valo
2020-11-02 18:13         ` Arend Van Spriel
2020-11-07 16:19   ` [v2] " Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).