From: Dongliang Mu <mudongliangabcd@gmail.com>
To: Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com,
gregkh@linuxfoundation.org, rkovhaev@gmail.com,
straube.linux@gmail.com, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Cc: Dongliang Mu <mudongliangabcd@gmail.com>
Subject: [PATCH] staging: rtl8712: Fix memory leak in r8712_init_recv_priv
Date: Mon, 24 May 2021 19:49:04 +0800 [thread overview]
Message-ID: <20210524114904.873174-1-mudongliangabcd@gmail.com> (raw)
The commit b4383c971bc5 ("staging: rtl8712: handle firmware load failure")
adds a goto statement when failing to load the firmware, however, it fails to
deallocate the resources (e.g., struct urb) allocated in the function
r8712_init_drv_sw.
Fix this by invoking r8712_free_drv_sw() before the goto statement.
backtrace:
[<00000000e0748eb7>] kmalloc include/linux/slab.h:557 [inline]
[<00000000e0748eb7>] usb_alloc_urb+0x66/0xe0 drivers/usb/core/urb.c:74
[<00000000fe5a9432>] r8712_os_recvbuf_resource_alloc+0x1b/0x80 drivers/staging/rtl8712/recv_linux.c:46
[<00000000923fed72>] r8712_init_recv_priv+0x96/0x210 drivers/staging/rtl8712/rtl8712_recv.c:54
[<000000000038512f>] _r8712_init_recv_priv+0x134/0x150 drivers/staging/rtl8712/rtl871x_recv.c:78
[<0000000066e70a4e>] r8712_init_drv_sw+0xa0/0x1d0 drivers/staging/rtl8712/os_intfs.c:312
[<000000001d2974c0>] r871xu_drv_init.cold+0x104/0x7d1 drivers/staging/rtl8712/usb_intf.c:391
[<000000001d449ce2>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
[<00000000cd123d34>] really_probe+0x159/0x4a0 drivers/base/dd.c:554
[<00000000364585cc>] driver_probe_device+0x84/0x100 drivers/base/dd.c:740
[<0000000048b74bde>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:846
[<00000000c358ab15>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
[<00000000bfa9b076>] __device_attach+0x122/0x250 drivers/base/dd.c:914
[<0000000048fe302a>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
[<000000002ceae175>] device_add+0x5be/0xc30 drivers/base/core.c:3109
[<00000000e4813a0d>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
[<00000000cbb8c98f>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
Fixes: b4383c971bc5 ("staging: rtl8712: handle firmware load failure")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
drivers/staging/rtl8712/usb_intf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index dc21e7743349..fd5da3a04b4e 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -599,8 +599,10 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
wait_for_completion(&padapter->rtl8712_fw_ready);
pnetdev = usb_get_intfdata(pusb_intf);
usb_set_intfdata(pusb_intf, NULL);
- if (!pnetdev)
+ if (!pnetdev) {
+ r8712_free_drv_sw(padapter);
goto firmware_load_fail;
+ }
release_firmware(padapter->fw);
if (drvpriv.drv_registered)
padapter->surprise_removed = true;
--
2.25.1
next reply other threads:[~2021-05-24 11:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 11:49 Dongliang Mu [this message]
2021-05-25 11:03 ` [PATCH] staging: rtl8712: Fix memory leak in r8712_init_recv_priv Dan Carpenter
2021-05-25 14:32 ` 慕冬亮
-- strict thread matches above, loose matches on Subject: below --
2021-05-21 12:08 Dongliang Mu
2021-05-21 12:09 ` 慕冬亮
2021-05-21 12:18 ` Greg KH
2021-05-21 12:24 ` 慕冬亮
2021-05-21 13:16 ` Greg KH
2021-05-21 13:42 ` 慕冬亮
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210524114904.873174-1-mudongliangabcd@gmail.com \
--to=mudongliangabcd@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=florian.c.schilhabel@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=rkovhaev@gmail.com \
--cc=straube.linux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).