Message ID | 20231214130407.3481513-1-alexious@zju.edu.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8526610dys; Thu, 14 Dec 2023 05:05:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKY1XNsbwCel5nFxQjak84GJ9oJAWpkw0kUl0G7jiSXeaRy5xzPAi0rzh5Dyfzco3QSIgB X-Received: by 2002:a05:6a20:9389:b0:18b:cc7e:de3 with SMTP id x9-20020a056a20938900b0018bcc7e0de3mr11697790pzh.41.1702559111673; Thu, 14 Dec 2023 05:05:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702559111; cv=none; d=google.com; s=arc-20160816; b=ewxh60fxiTklX/kmY4n9dbdNoHn7MP28nicDzF57BMW+Pnl7E9h3iwgTLI5m+D4MKZ L0O0esYSv3UohvL92fJ1fzipD0DNCd14sOlevaO24z4IcGs97xoyFbuAvCztwDQB2fwB kNOzl2M2FZbdO5rAXHTO9wmYIuXi02uCGa8rHfg7dtYR+ZjAWDC3f6ahe0BDrBPOsg7i ekCuzqLXfs77tzvX0o0N2UaZDiwgeajeLpUWqzaq6oZ1ceWp/KcDFXSceciGY8wd9b3o gwDvlJwSi2riKAXwBu6ExxkcVun8LF1p2c8ZJ0LMvfwcULUuMEHg6tlFR+5uZqhw3ADh g9CA== 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=4XFHjz1KKzpswaG0MiV1y/iZHRxLS8zBxbEH56cPfzY=; fh=3aHqsxjUkLNb60gepg+jDJty6fbyjnorbBXO2CP0MwU=; b=WVYW0Y0hYptahYvGnjQ2UOejsxPxxbWwWbKWF2Z6Dfd4d61VWy14L6daWFBvhwXURM 2sFPUurUkPj3pGT4c5tGZ5R4i8piF07w+/bVpoYRNlSZ3INcKhv+OJiqZvE53Jfofs3Y sk4sfGS08KjbbxQhZUcXB+vdHrfMSn622N/kUhPQp/h1A/fnbkgOUAWK8I9xMVKkkCDp 8d2YZbDuS4mTpEx2FUFjrLNzqQrPA64j94f7RGKAleuSeO/kb1KiZFx9ec6OV9AaBJxR Qm5LiWq2QZPXW8mL11P2Eyn/UQjg635/NBEsvWSh8iBpUHNr7n3GgsOSnrQaxFExgksm Yu4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m128-20020a632686000000b005c66a7d710bsi11130107pgm.459.2023.12.14.05.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 05:05:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id ADAD48160398; Thu, 14 Dec 2023 05:05:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573177AbjLNNEz (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Thu, 14 Dec 2023 08:04:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573145AbjLNNEy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 14 Dec 2023 08:04:54 -0500 Received: from sgoci-sdnproxy-4.icoremail.net (sgoci-sdnproxy-4.icoremail.net [129.150.39.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 637AA98; Thu, 14 Dec 2023 05:04:56 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [122.235.241.73]) by mail-app4 (Coremail) with SMTP id cS_KCgAHfTRQ_XplJfGUAA--.32770S2; Thu, 14 Dec 2023 21:04:16 +0800 (CST) From: Zhipeng Lu <alexious@zju.edu.cn> To: alexious@zju.edu.cn Cc: Suman Ghosh <sumang@marvell.com>, Chris Snook <chris.snook@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Yuanjun Gong <ruc_gongyuanjun@163.com>, Jeff Garzik <jgarzik@redhat.com>, Jie Yang <jie.yang@atheros.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources Date: Thu, 14 Dec 2023 21:04:04 +0800 Message-Id: <20231214130407.3481513-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cS_KCgAHfTRQ_XplJfGUAA--.32770S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KF47Xr1DtF45Zr4ktrWfAFb_yoW8Gr1fpa yvk3yDGrZ2vw15tanrAw18XFZYkan8tryv9FW3Gw4fZFy0yF1jvryqk34j9ry8C3y09r13 ZF1UZ348GFnxtw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvC14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2 Y2ka0xkIwI1lc2xSY4AK67AK6ry8MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r 1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CE b7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0x vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAI cVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2Kf nxnUUI43ZEXa7VUjHGQDUUUUU== 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 lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 05:05:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785262623029345415 X-GMAIL-MSGID: 1785262623029345415 |
Series |
[v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources
|
|
Commit Message
Zhipeng Lu
Dec. 14, 2023, 1:04 p.m. UTC
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 <alexious@zju.edu.cn> Reviewed-by: Suman Ghosh <sumang@marvell.com> --- Changelog: v2: Setting tx_ring->tx_buffer to NULL after free. v3: Moving free and set-null operation to a new label free_buffer. --- drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Comments
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Thu, 14 Dec 2023 21:04:04 +0800 you wrote: > 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 <alexious@zju.edu.cn> > Reviewed-by: Suman Ghosh <sumang@marvell.com> > > [...] Here is the summary with links: - [v3] ethernet: atheros: fix a memleak in atl1e_setup_ring_resources https://git.kernel.org/netdev/net/c/309fdb1c33fe You are awesome, thank you!
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c index 5935be190b9e..5f2a6fcba967 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c @@ -866,10 +866,13 @@ 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; - goto failed; + goto free_buffer; } return 0; +free_buffer: + kfree(tx_ring->tx_buffer); + tx_ring->tx_buffer = NULL; failed: if (adapter->ring_vir_addr != NULL) { dma_free_coherent(&pdev->dev, adapter->ring_size,