[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210524114904.873174-1-mudongliangabcd@gmail.com>
Date: Mon, 24 May 2021 19:49:04 +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>
Subject: [PATCH] staging: rtl8712: Fix memory leak in r8712_init_recv_priv
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@...il.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
Powered by blists - more mailing lists