[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210521162519.677074-1-mudongliangabcd@gmail.com>
Date: Sat, 22 May 2021 00:25:19 +0800
From: Dongliang Mu <mudongliangabcd@...il.com>
To: Larry.Finger@...inger.net, florian.c.schilhabel@...glemail.com,
gregkh@...uxfoundation.org, rkovhaev@...il.com,
straube.linux@...il.com, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Cc: Dongliang Mu <mudongliangabcd@...il.com>,
syzbot+1c46f3771695bccbdb3a@...kaller.appspotmail.com
Subject: [PATCH v2] staging: rtl8712: Fix memory leak in r8712_init_recv_priv
r871xu_dev_remove failed to call r8712_free_drv_sw() and free the
resource (e.g., struct urb) due to the failure of firmware loading.
Fix this by invoking r8712_free_drv_sw at the failure site.
Reported-by: syzbot+1c46f3771695bccbdb3a@...kaller.appspotmail.com
Fixes: b4383c971bc5 ("staging: rtl8712: handle firmware load failure")
Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
---
v1->v2: fix the initialization of pnetdev
drivers/staging/rtl8712/usb_intf.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
index dc21e7743349..57e773464e18 100644
--- a/drivers/staging/rtl8712/usb_intf.c
+++ b/drivers/staging/rtl8712/usb_intf.c
@@ -593,13 +593,14 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
struct usb_device *udev = interface_to_usbdev(pusb_intf);
if (pnetdev) {
+ struct net_device *newpnetdev = NULL;
struct _adapter *padapter = netdev_priv(pnetdev);
/* never exit with a firmware callback pending */
wait_for_completion(&padapter->rtl8712_fw_ready);
- pnetdev = usb_get_intfdata(pusb_intf);
+ newpnetdev = usb_get_intfdata(pusb_intf);
usb_set_intfdata(pusb_intf, NULL);
- if (!pnetdev)
+ if (!newpnetdev)
goto firmware_load_fail;
release_firmware(padapter->fw);
if (drvpriv.drv_registered)
@@ -625,6 +626,10 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf)
*/
if (udev->state != USB_STATE_NOTATTACHED)
usb_reset_device(udev);
+ if (pnetdev) {
+ struct _adapter *padapter = netdev_priv(pnetdev);
+ r8712_free_drv_sw(padapter);
+ }
}
static int __init r8712u_drv_entry(void)
--
2.25.1
Powered by blists - more mailing lists