lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <tencent_75E5FF1DC8353370AE0F4712454D78BC9206@qq.com>
Date:   Thu, 31 Mar 2022 19:11:23 +0800
From:   xkernel.wang@...mail.com
To:     gregkh@...uxfoundation.org, dan.carpenter@...cle.com
Cc:     Larry.Finger@...inger.net, phil@...lpotter.co.uk,
        linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc()

From: Xiaoke Wang <xkernel.wang@...mail.com>

in rtw_os_xmit_resource_alloc(), if `pxmitbuf->pxmit_urb[i]` is
allocated in failure, the other resources allocated by this function are
not properly released.
This patch is to free them.

Signed-off-by: Xiaoke Wang <xkernel.wang@...mail.com>
---
 drivers/staging/r8188eu/os_dep/xmit_linux.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c
index 8c3f8f0..5a59f62 100644
--- a/drivers/staging/r8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c
@@ -78,8 +78,12 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb
 
 	for (i = 0; i < 8; i++) {
 		pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
-		if (!pxmitbuf->pxmit_urb[i])
+		if (!pxmitbuf->pxmit_urb[i]) {
+			while (i-- > 0)
+				usb_free_urb(pxmitbuf->pxmit_urb[i]);
+			kfree(pxmitbuf->pallocated_buf);
 			return _FAIL;
+		}
 	}
 	return _SUCCESS;
 }
-- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ