From patchwork Fri Dec 8 08:23:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 175676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5316050vqy; Fri, 8 Dec 2023 00:23:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMkQefalB9u/QmiYwoajetDSR7CCIvuSKB2JdejA7t4zaFgqqh9zQyIu0MbYNx91Lwyn6V X-Received: by 2002:a17:90a:ab11:b0:28a:3836:600e with SMTP id m17-20020a17090aab1100b0028a3836600emr241285pjq.60.1702023833188; Fri, 08 Dec 2023 00:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702023833; cv=none; d=google.com; s=arc-20160816; b=xOsIVnMnL/RV1JG4kYZ7Dut6d+8VOUR1z89xzCyXeYQEC0WIPYrjGP9yMbMy0KHJ2W ACNLUcabdUcTzSDfcwBiwhuustfIjyR3L8wprQUxu+Kt70f4XXNTnAt4i4s6TQviv7eP xBRabfHnwcgFue8z0QjDwY9JTe6DCCgic0gpm2k28AeCzuQ1AORM13M9MgMOOt3B3mc5 UcCTswaqqMHRN2w79/PtTprOcdjcPOsC640b8/nVgQLAtfB/rquP5qC2GKVIL+hhO6C1 dbsvN3rJeZ1uqEU/Cyitk0YCV4nO1DMsHHtFeAr3lCwYqVxSbE6geKI81gb0hIZbT84X BtkA== 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 :message-id:date:subject:cc:to:from; bh=B+d9bOEsGa9YH1wef8NzMHMytkHwWipC+90zqSDWRQc=; fh=7dBhDwlLSu4LpNvs6Ci/8kzDCbY2AHDy/bapchU2IsY=; b=auyc4rjEAeyXnh9JzHnhOWLU1BccmsbSiEB6Zh8mrfx+loQTbBYo8sbwMJfW2fdMrV nzVD9z+4Gu7B8wWiOMQrQ9QP/atOLh4J3MCroUMrBF2Esx8HNkiw4wP/o7Spu2CLcfTI T2XXEROfhmjmS3SSmTAhU75rcnys0KraMZ81DtjuwDClmagYb5fGj8qZWufcwrszbMS3 /iPbb8zC/hzd31pUnRoiB4eI83kTqbxMhfTzjsV6Ofx02idr6qxGGY5H62tzLxU7KHLY l6eSslO9hvvfB8buRQBxX3Mm4aUDkvCZp4Zyq3K/AnHC4+8+W09LocT5F71Vz3sjGD7n cj4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id nd12-20020a17090b4ccc00b0028a1f44900esi1265425pjb.94.2023.12.08.00.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 00:23:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 74F048043ADD; Fri, 8 Dec 2023 00:23:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573289AbjLHIXl (ORCPT + 99 others); Fri, 8 Dec 2023 03:23:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233002AbjLHIXj (ORCPT ); Fri, 8 Dec 2023 03:23:39 -0500 X-Greylist: delayed 621 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 08 Dec 2023 00:23:43 PST Received: from zg8tmtu5ljg5lje1ms4xmtka.icoremail.net (zg8tmtu5ljg5lje1ms4xmtka.icoremail.net [159.89.151.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0E1B10E6; Fri, 8 Dec 2023 00:23:43 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [125.119.254.181]) by mail-app3 (Coremail) with SMTP id cC_KCgA3ro1_0nJla0uWAA--.20728S2; Fri, 08 Dec 2023 16:23:28 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Chris Snook , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Yuanjun Gong , Jie Yang , Jeff Garzik , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Date: Fri, 8 Dec 2023 16:23:14 +0800 Message-Id: <20231208082316.3384650-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: cC_KCgA3ro1_0nJla0uWAA--.20728S2 X-Coremail-Antispam: 1UD129KBjvdXoW7GF1ruw4kGF17GrWDtF48tFb_yoWDZFbEgw s2gw18Wanxtr1jkw42yr4ru3yqk34kWws3Ga97KFW3Zw47Aw1UZ34vgrn3Xr1I9r4fAFy3 Ar1aqF18Aa4DKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb4AFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j 6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrV AFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCI c40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267 AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbXdbU UUUUU== X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 08 Dec 2023 00:23:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784634370732940792 X-GMAIL-MSGID: 1784701343078151449 In the error handling of 'offset > adapter->ring_size', the tx_ring->tx_buffer allocated by kzalloc should be freed, instead of 'goto failed' instantly. Fixes: a6a5325239c2 ("atl1e: Atheros L1E Gigabit Ethernet driver") Signed-off-by: Zhipeng Lu Reviewed-by: Suman Ghosh --- Changelog: v2: Setting tx_ring->tx_buffer to NULL after free. --- drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 5935be190b9e..1bffe77439ac 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -866,6 +866,8 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter) netdev_err(adapter->netdev, "offset(%d) > ring size(%d) !!\n", offset, adapter->ring_size); err = -1; + kfree(tx_ring->tx_buffer); + tx_ring->tx_buffer = NULL; goto failed; }