Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp811992pxb; Thu, 31 Mar 2022 19:02:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQt/yeluRuz/mI8pSbR92+BmkzJGGFuN686iSpHMT5CTZ4tYDC4nA/M9SRf6Z0EhHQ4dtq X-Received: by 2002:a17:906:f956:b0:6df:d816:264b with SMTP id ld22-20020a170906f95600b006dfd816264bmr7472636ejb.354.1648778519972; Thu, 31 Mar 2022 19:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648778519; cv=none; d=google.com; s=arc-20160816; b=QMlMR4H6axxHlTRyPcojQRrzV96B4HLWRc6uhyaEsyVEs0/Ob3jWf1JGm5x8Xp2P7T SkW1HDZrj+AMX5q58Fr8mVQe1Km7cZ2tF7ghoKg4gdnO7QVtaTc5ZxkZlD0085u0tCMC mLol0wll8Tjl8y7ezDC+U5QSH8vrs29HQrHzcp9WyMCGB/D8TtrR5IeyETfSo5mV96F5 YBZyBWrKkIhOdmaduJIw6LX56XpPIHJsERc7FsejvV7r+LPq0QsG0tjiMNakpnLPyzlc 1d3Tg04fvtSJViTtC6u2Oq3vI/d1U+IfZ5ASm99NR1/bEYiAvJgk0OkF4TRW2k8QUMCL wBow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:date :subject:cc:to:from:message-id:dkim-signature; bh=elyHlnyePDXKN3P2xm16PGMA5PP2gZ61mI8T7iBUoRk=; b=niLO5zj6pZjHMQklfz+FIRzQ55xdT0OU/3Ybn68h4U++YPKepm0MIzbbhwANnLCl4H ZVSpZLGEW6h+Jb3ftr9yeT7RNjS3k8LwuC1otvaARXSOB/qAfhDR5t9x+Urb7f+gCJ8y MCkhPl9LmptX81TcfNTCOZpeUqbduUEYDLIX1Yd+3CWhZJ7ZULW/ylfz7QQ4iHTmdeqG AlgfD56WW/c+PsiOhnUi6wjT/Ufx4yDkcH2BxrTUsI9QZrAfX8tak7KK9UGDGRRwX5hw xCoOHslkh6jnJP8IsQUXHhrEhutK7hAeOSpwFTO37c0Q5huu0jc3qHiMg2GB759o/wGu c+GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=N6gOojrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ox4-20020a170907100400b006e493c7eb37si770055ejb.488.2022.03.31.19.01.35; Thu, 31 Mar 2022 19:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=N6gOojrt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234965AbiCaLNm (ORCPT + 99 others); Thu, 31 Mar 2022 07:13:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233641AbiCaLNj (ORCPT ); Thu, 31 Mar 2022 07:13:39 -0400 Received: from out203-205-251-80.mail.qq.com (out203-205-251-80.mail.qq.com [203.205.251.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C48654BF for ; Thu, 31 Mar 2022 04:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1648725108; bh=elyHlnyePDXKN3P2xm16PGMA5PP2gZ61mI8T7iBUoRk=; h=From:To:Cc:Subject:Date; b=N6gOojrtwo8G4mXrmShY9gX2uuZHat9H6NXUBgYl9t3bv6uRufdPXmS/It9FyDXB8 CQvvdWZfd0YW99w/PEgk+yhYjvWyp3+IKCDOXv16PkAwSbyXlgCJZ6e9kPfbvCPn6P 9uNB01rpDdjpGJg0+LTcJN2S/PSo0/6WCd3ivCWs= Received: from localhost.localdomain ([43.227.138.48]) by newxmesmtplogicsvrszc9.qq.com (NewEsmtp) with SMTP id 2ECB38A4; Thu, 31 Mar 2022 19:11:44 +0800 X-QQ-mid: xmsmtpt1648725104tagn79hsi Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjTDt3SiOUav6tw+MCRYiTRtGQVKAlqhrPGowt5/T9fIFV60L30C hrQw0RwamAI8GGfFPKVNA+WEw4T8imN7Jc11+Uq1At7F5LzV+7XlbeTULSE8hOzvheFKi89BndAS iKDt+d5jeWoC9oU2vjCtKvAeJtNiEDL1GWKYniQF+rYZCy2Szun90dO0NLcC/LSXbOFBTg/DtVeU 6xDRS05bisNYZbZjO0sJ67UWrWvPsTT/ALRR249kNA1WtmjM21AUjIvjMTP7QKWy0azWF42GIYsW YW5kiG4PHxKpsYS+3W6GGpSgClLvrqBF64lCZa+ob+au/KtrdAp70RvjeYTH2WGwmXg/nyWfTBpY GIa4R2hSDK2cLQHMesO0SfAnAaV/sXDmZcM6xYC7fCokf/Y+kcov35wa26LU9vyV1I/Fa9HeRUYb PlgY9ZP+H68LeJXIPTMw/NPu6e+kbBMhstxxNj1pGBMA+2yYCNLMOQ03vu+k07rZfP/yLcMj2GIA MaaURYe2Drcd37di8xiDtyZULqxmZPniD1J9FuZ/VRNVRYZInb1LAp9Oki2pUif1KQdIv19czxxP a2J5AwtrH+MbMf6xsD/qGzouFR5fcmzoXd7t5T2hUxo7MyQtk1W9s42Nmukuqu7V5bZqohg0VCEg 3TCbTeiCj+pAiiuZ5a/SuKrdsH7doK99siknVfCN0Ol9FXLyfpE9NeDL+7JaVtw+THPWE9cNosmZ tReJrKtemhr6jyRNMD/7sc/3zpUkAbJTdcroensdBYNxCrKIPD6qeyvmVw3RS/8Os5RYAwCCs7ti c8vUdF5SAfceXkhRiay446lDL18nylOBW9Or8uLL+MaZ7B5htQXGEgb5j3YpXLCWs/RGx4ypkvAZ 7oo2065STSBx5KSvrC826l33GXH+BU/YWCKW+QZsxg4AYRzR6w1fab1S6pZ0uVAdjIgaIwCi77bL D9yMeEBgDVA1/rEEQSsw== From: xkernel.wang@foxmail.com To: gregkh@linuxfoundation.org, dan.carpenter@oracle.com Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] staging: r8188eu: fix potential memory leak in rtw_os_xmit_resource_alloc() Date: Thu, 31 Mar 2022 19:11:23 +0800 X-OQ-MSGID: <20220331111123.8113-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RDNS_DYNAMIC,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoke Wang 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 --- 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; } --