netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtlwifi: fix memory leak in rtl_usb_probe
@ 2019-10-04 19:53 Navid Emamdoost
  2019-10-05 16:08 ` Markus Elfring
  0 siblings, 1 reply; 3+ messages in thread
From: Navid Emamdoost @ 2019-10-04 19:53 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Ping-Ke Shih,
	Kalle Valo, David S. Miller, linux-wireless, netdev,
	linux-kernel

In rtl_usb_probe, a new hw is allocated via ieee80211_alloc_hw(). This
allocation should be released in case of allocation failure for
rtlpriv->usb_data.

Fixes: a7959c1394d4 ("rtlwifi: Preallocate USB read buffers and eliminate kalloc in read routine")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 4b59f3b46b28..265f95261da8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1021,8 +1021,10 @@ int rtl_usb_probe(struct usb_interface *intf,
 	rtlpriv->hw = hw;
 	rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
 				    GFP_KERNEL);
-	if (!rtlpriv->usb_data)
+	if (!rtlpriv->usb_data) {
+		ieee80211_free_hw(hw);
 		return -ENOMEM;
+	}
 
 	/* this spin lock must be initialized early */
 	spin_lock_init(&rtlpriv->locks.usb_lock);
-- 
2.17.1


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

* Re: [PATCH] rtlwifi: fix memory leak in rtl_usb_probe
  2019-10-04 19:53 [PATCH] rtlwifi: fix memory leak in rtl_usb_probe Navid Emamdoost
@ 2019-10-05 16:08 ` Markus Elfring
  2019-10-05 19:00   ` Navid Emamdoost
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Elfring @ 2019-10-05 16:08 UTC (permalink / raw)
  To: Navid Emamdoost, linux-wireless, netdev
  Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, David S. Miller,
	Kalle Valo, Ping-Ke Shih, linux-kernel, kernel-janitors

> In rtl_usb_probe, a new hw is allocated via ieee80211_alloc_hw(). This
> allocation should be released in case of allocation failure for
> rtlpriv->usb_data.
>
> Fixes: a7959c1394d4 ("rtlwifi: Preallocate USB read buffers and eliminate kalloc in read routine")

Which event did trigger the sending of this patch variant
after a similar change was integrated already?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=3f93616951138a598d930dcaec40f2bfd9ce43bb
https://lore.kernel.org/lkml/20191001092047.71E8460A30@smtp.codeaurora.org/
https://lore.kernel.org/patchwork/comment/1331936/

Regards,
Markus

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

* Re: [PATCH] rtlwifi: fix memory leak in rtl_usb_probe
  2019-10-05 16:08 ` Markus Elfring
@ 2019-10-05 19:00   ` Navid Emamdoost
  0 siblings, 0 replies; 3+ messages in thread
From: Navid Emamdoost @ 2019-10-05 19:00 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-wireless, netdev, Navid Emamdoost, Kangjie Lu,
	Stephen McCamant, David S. Miller, Kalle Valo, Ping-Ke Shih,
	LKML, kernel-janitors

Oh! It's duplicate, thanks for catching that.

On Sat, Oct 5, 2019 at 11:08 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> > In rtl_usb_probe, a new hw is allocated via ieee80211_alloc_hw(). This
> > allocation should be released in case of allocation failure for
> > rtlpriv->usb_data.
> >
> > Fixes: a7959c1394d4 ("rtlwifi: Preallocate USB read buffers and eliminate kalloc in read routine")
>
> Which event did trigger the sending of this patch variant
> after a similar change was integrated already?
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=3f93616951138a598d930dcaec40f2bfd9ce43bb
> https://lore.kernel.org/lkml/20191001092047.71E8460A30@smtp.codeaurora.org/
> https://lore.kernel.org/patchwork/comment/1331936/
>
> Regards,
> Markus



-- 
Navid.

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

end of thread, other threads:[~2019-10-05 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 19:53 [PATCH] rtlwifi: fix memory leak in rtl_usb_probe Navid Emamdoost
2019-10-05 16:08 ` Markus Elfring
2019-10-05 19:00   ` Navid Emamdoost

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).