[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_35C87F0B0813734E6E3DC7100565789CD206@qq.com>
Date: Fri, 1 Apr 2022 02:11:41 +0800
From: xkernel.wang@...mail.com
To: gregkh@...uxfoundation.org
Cc: Larry.Finger@...inger.net, florian.c.schilhabel@...glemail.com,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] staging: rtl8712: fix potential memory leak in r8712_xmit_resource_alloc()
From: Xiaoke Wang <xkernel.wang@...mail.com>
In r8712_xmit_resource_alloc(), if usb_alloc_urb() fails, there are some
explored items should be released before this function returns.
Signed-off-by: Xiaoke Wang <xkernel.wang@...mail.com>
---
drivers/staging/rtl8712/xmit_linux.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c
index 06283c4..1bfa204 100644
--- a/drivers/staging/rtl8712/xmit_linux.c
+++ b/drivers/staging/rtl8712/xmit_linux.c
@@ -113,6 +113,8 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter,
pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!pxmitbuf->pxmit_urb[i]) {
netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n");
+ while (i-- > 0)
+ usb_free_urb(pxmitbuf->pxmit_urb[i]);
return -ENOMEM;
}
kmemleak_not_leak(pxmitbuf->pxmit_urb[i]);
--
Powered by blists - more mailing lists