Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3259443rwb; Fri, 30 Sep 2022 00:31:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4bV+WT5Edp8zUlPmleIBPQJc+PKj9a1B8TS+3c6QSKsyunpRryzbmO2dQcNRL3S2OKVzfD X-Received: by 2002:a63:4805:0:b0:43b:e1c9:32af with SMTP id v5-20020a634805000000b0043be1c932afmr6559055pga.574.1664523069124; Fri, 30 Sep 2022 00:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664523069; cv=none; d=google.com; s=arc-20160816; b=DVoO8uQGfxrhrPzxCTe5MzZkrk/jki5Lira8Nu/WYAyO3Ds5rf6NY90NLU+pLLH+AF 2TLMUWoeTtL53Jf8f4FgCL2FaLTG8izSXxAcn0DCcOiiRqBsZFOM7IBfMXwtreBYAQct IPoO4u4q/TfKI3VuqlTkME+oxr2mwUwHCHQ6XN0fiSXcrTu5FWl/jlrFuW/0SpNc/8zR Iika29n6qFK+P7TBi4c1TIbsHYrhYkITZ06YUv74iFuu13YwTVB8TZmdR8vybx3kDBQu Y1/dB7Msa4dh3XOq9qHaVMHZ47ezNBZyKz0hmCsX2wuG9gNpmEiFKcOwFCu4Y9xKwbPZ OPBw== 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:dkim-signature; bh=TeC9GwZOg9/n2xD1WVfGuCZoPfKYMRWZ2un6aSADwLY=; b=ZZwFxEHeQvBmTviZXZGF7rI/BDxJUqhzpD6TY5tM5wItwDZsO7DY5rpyWeGW5Xu29y aHCApBBY9jcCysJf9g9i2M0rM6uk8viZ23p1PhZAYlTUyxi8vKqbIzAei5fTVbFHMHog lWLBBUIl8SZGWvlPjv+dLoqw8lmws4yKUx40VM0X4MKops7N1F10Ga+UVyq/w29fdJzX gnL8GUDlMAVcNnRkz27m0fnpeeTuwkH7rqWNe64Y7G8eVFTv6KLOib++BnvE0L3FWDQa RvAJpqZFr7AuVSYgCOKxI4ELQCIUt/WzPz3nFMyfUTvoML/x799KHxfTOkhrCAUnwcDd kwGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=T5B8wTcU; 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=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a6-20020a056a000c8600b0053f6f9b00b7si1479109pfv.81.2022.09.30.00.30.57; Fri, 30 Sep 2022 00:31:09 -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=@163.com header.s=s110527 header.b=T5B8wTcU; 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=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbiI3GaI (ORCPT + 99 others); Fri, 30 Sep 2022 02:30:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbiI3GaH (ORCPT ); Fri, 30 Sep 2022 02:30:07 -0400 Received: from mail-m975.mail.163.com (mail-m975.mail.163.com [123.126.97.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0CA42D1D8; Thu, 29 Sep 2022 23:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=TeC9G wZOg9/n2xD1WVfGuCZoPfKYMRWZ2un6aSADwLY=; b=T5B8wTcUH2T9lpmd4DtsY xbwZWA5gAysDiN99ay9JZfXLrzI2IAtq02ZtA6/D3aXbu3vMcK8mJ7/DCeI0XHDN aMhgeMjv6NaCDm5i5UGLFp+z4rPN3Ytt6xJpmbFVxcyt7Ri7q/sj2KpaS9ZSVpOH b1WG+x3kcpgXuTQbACMc4w= Received: from localhost.localdomain (unknown [36.112.3.106]) by smtp5 (Coremail) with SMTP id HdxpCgAXcgicjDZjHxHXgQ--.36896S4; Fri, 30 Sep 2022 14:29:03 +0800 (CST) From: Jianglei Nie To: aelior@marvell.com, skalluru@marvell.com, manishc@marvell.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Fri, 30 Sep 2022 14:28:43 +0800 Message-Id: <20220930062843.5654-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgAXcgicjDZjHxHXgQ--.36896S4 X-Coremail-Antispam: 1Uf129KBjvJXoWrKF13CF1rWw17Gry3WF1rZwb_yoW8Jr1kp3 yqqFyDAr18trsYka1DJ3W8Zr98Z3y5t34j9ay3Z3yF93y5tr4UJrsrKay29ryDJrWrKr12 vr45Z3sxXa4qvw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziCPfPUUUUU= X-Originating-IP: [36.112.3.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiWw+MjGI0Wa2DewAAsO X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 bnx2x_tpa_stop() allocates a memory chunk from new_data with bnx2x_frag_alloc(). The new_data should be freed when gets some error. But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns without releasing the new_data, which will lead to a memory leak. We should free the new_data with bnx2x_frag_free() when "pad + len > fp->rx_buf_size" is true. Fixes: 07b0f00964def8af9321cfd6c4a7e84f6362f728 ("bnx2x: fix possible panic under memory stress") Signed-off-by: Jianglei Nie --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 712b5595bc39..24bfc65e28e1 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -789,6 +789,7 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n", pad, len, fp->rx_buf_size); bnx2x_panic(); + bnx2x_frag_free(fp, new_data); return; } #endif -- 2.25.1