Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1152628pxb; Wed, 6 Apr 2022 09:57:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdmx2BG3J80Mp2q9mJRSSem/FXujLbxtTZyPBZPtVOkn4yBuwiV0SUmYol2BHQPqZn2aUa X-Received: by 2002:a63:5545:0:b0:399:2b1f:a0c8 with SMTP id f5-20020a635545000000b003992b1fa0c8mr7886192pgm.175.1649264270342; Wed, 06 Apr 2022 09:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649264270; cv=none; d=google.com; s=arc-20160816; b=hPUbSB47TPaib7/7mdhgMeRiQEl+V7+qn/cUewbKvr5NeXsdbe8gtkySCQpH27s2Zv RCfmhYG2nlKabVpOtn59fmGQJWZC3V2bneipLKXfXPsSG2fooKwHirvAPoC8O3AAoo4B gPZUMVy0yEEaez6FGPrDqSctLDWuc3lOHUtO05mzO9bnH3xipHDJReaByQRSk4W3bwMs kh/qnaGlKd1HHB9ocUa7IRo0I0Jk0cTQuZ91P6d9P2Lp6TWUDFppjaz48ytUZKHqBKxG FREwgZhgBGbfl1zvsUcvor1n0n+757WqH0xTsn3yFnjku3yWJ26uc24xlfJzsT4L79X9 N15w== 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=/3v/n9JdJY9saPfEt6mwbCOo5wF4ZWKg9nyuXSpL/9o=; b=KtZDkeiltjZZh3FFseMyMKZZtZC9kBIQrmSDGFuMnPVSa54spyA7OmRzfaIL1U8CZq UQGwq50JE8U+sm1KotBEO2cyJz76tno9F3uJf0Hkwr5vcfakEZbL4leJtEqVUaHYBIgE tenrNjWoSfhoZysl2dz8OcS0tOW4SrsEECczTK2HK0FQEE0E3ehJLOMiuk4kyWJUKDUt pI4+NyenKkjb1NWO7maz9GrzMMnfJd0a3nXuqRyiZwdoKkw3oUKWGot/nnOAJjLrvpdv sk/SONgGt6DEXkSjzlhR+E0fjxQO6OHdlrEfRH/FDGTtDlmHYwW/4jC23+mr3Tc/DYv9 NjYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b="Z/8fMC2e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ay7-20020a056a00300700b004fa3a8e004csi16108159pfb.259.2022.04.06.09.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b="Z/8fMC2e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D58E51704F7; Wed, 6 Apr 2022 09:14:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237379AbiDFQQV (ORCPT + 99 others); Wed, 6 Apr 2022 12:16:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237381AbiDFQQN (ORCPT ); Wed, 6 Apr 2022 12:16:13 -0400 Received: from out203-205-221-245.mail.qq.com (out203-205-221-245.mail.qq.com [203.205.221.245]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26CAB1AD1FD for ; Tue, 5 Apr 2022 20:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1649217185; bh=/3v/n9JdJY9saPfEt6mwbCOo5wF4ZWKg9nyuXSpL/9o=; h=From:To:Cc:Subject:Date; b=Z/8fMC2eyMMGrdbh/tCxFMovJMt+6JN57CnQVvkSANSYcAscA0JReqCofMa/jqigF OhhFJ1QPFqowsqKVDhvTxEv9kT6jPhbu9GesNzz4WvPwQ/Ic71EOHSII/zkcNzYYVI n69xW/ojzgy2hWNs9wwTnVGIU+4UI6vbYolYYpLA= Received: from localhost.localdomain ([43.227.138.48]) by newxmesmtplogicsvrszc7.qq.com (NewEsmtp) with SMTP id D422002D; Wed, 06 Apr 2022 11:53:02 +0800 X-QQ-mid: xmsmtpt1649217182td0indq9y Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjlcvuejhie0WMTAU+d81tm9s6Jv1nFWGjhjJ4MNjXOZq43kjLv7 pwA0Ny9Egj4o4m6ocfIWk7ut04zOPpy/KfySOf96JdTu1cf9TrwkO8/MsybjrniZVSNzgOCr7wSS hm0zIWB8mAwpPu2cupXBkmM8bqErBY9LBs3GpaZq0TCgeHfYCAFp/XAB1SCippNC8oVuJzGHJ48n +sducBurCMIqdP0RfzAoM/OMtrtYuPKwCQUEa9pepWawMYGJCaHuhc5Y+KEqtlzuNyFhxi5/tO8I wj4icrQ0Po6Bu+YMqjw9jnGjuRJMVKC/Ul0bzInz1E1Z4wf54ydAX/3qwoPQDNPVWT/iitChNhdw 8rReJ6OF5tYOsOSjU1dJc13OGO+RaN3H+huDOOeNz/moQ9PZrzA92zmLZCEJzTlqo0tCBu79n5u7 OhGTH0pyPl6pgjp1yuv1ZXdaSNL3u4qssLelXj6aO/Ty+qjxaRYc9YzPdNY8+OLZ9K3T7Dp6Niyw qQhl/HaAYZbDykr2PpHPM9fwRxvAccWaniFmDLBMdUM3uEGqHq7ATCg2BPo+svuMxsj/TftW7k30 +sV2yJxd6n8ikP2OP+kieT/BZ/Bwu4mHC5bp+zZVHYMbZfRBeCGH0jb2jncLXPjEEqpruRydNJkr OIadWCQm8S8g9XH7KczZqCuA0HAEcG5PVHurXeTNatuo5pFyjxVxxpUSsk95EVYQlDABhjbDQ8VY vGDRyAEpFjDjKHeYWGhZp6etKmpmmPfAgHw95pjzbXO27qBp8Vd5H1s+cwOLeA0JzB55xIcr0IAC v2DQ9WeVr6HBV2Miw1NKe/NMqc214mifFcMaTP2s4q54ANTRju+dcTVlIJElMPlIbHDyPsr3z06P LuvCr8U4/ZlgLhoxoQcv5o/5H8IBWAHiz6W0kPC9uAQSfBYY5CukxfmlWblKNUfdJUmtNdJKW+C/ +YUrxqMjyMl7Hn7GczXDosmh8fx+5I From: xkernel.wang@foxmail.com To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, florian.c.schilhabel@googlemail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH v2] staging: rtl8712: fix potential memory leak in r8712_xmit_resource_alloc() Date: Wed, 6 Apr 2022 11:52:52 +0800 X-OQ-MSGID: <20220406035252.12835-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,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 r8712_xmit_resource_alloc(), if usb_alloc_urb() fails, there can be some explored items are not released before this function returns. Therefore, this patch re-explores the allocated items and uses usb_free_urb() to release them. Signed-off-by: Xiaoke Wang --- ChangeLog: v1->v2 remove kmemleak_not_leak() and update the description. drivers/staging/rtl8712/xmit_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 4a93839..034de02 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -113,9 +113,10 @@ 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]); } return 0; } --