Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp26966iog; Thu, 23 Jun 2022 21:21:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3CWauhSTmIgoR0sVBeCaxjanDXaVq49PuDXXPpx9RR6TeCC+RpGBakVM1Ml9LtKvrG0+Y X-Received: by 2002:a17:902:b496:b0:16a:1630:a944 with SMTP id y22-20020a170902b49600b0016a1630a944mr28781627plr.147.1656044515634; Thu, 23 Jun 2022 21:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656044515; cv=none; d=google.com; s=arc-20160816; b=SVlk7xZsLYqH9G6+815Jp5jY+O6ynz+4hrKf92bq74ZAaKz4nXPN34ykETf/GO3EQN no5zEXmP6hgYiQN1gzPxStHzfdajuW/yFbuRQbrpK75GaO4w0My0PHlqGuRPuaABwSdj 069XNdXV7moGeHAnVRH83aiAILW4fRoVUJjdiulbK5QMAZKkVgTAkmW61CuPg1vSjTZc ky+1zWuIRiBTkhe2rDoIB3gA/eoBEEp9VxqpOQ3c8BGVzXDQdhJ0+v9uk3nasBrhyQMR es8xRxBi1lrcMYUPMa/OwKFQuTWM9K2fllYD9RnTWD22SNT+Q4XauuQT7G26bdM9baWk mWdQ== 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=E5epVJPg/t9YUTy8EYdJ5qpvHm/ag92IRP9C9ezExQ8=; b=aLOP6afdgars2nBa4zha+1YKDg1aZ9UOxDEhJyH6Db92s9nDVvfStuIzQDC0mQu5Ri MEGhsWhtRMUf0B8eBE1pWCo/ZZ+CrVbkGassEqu47Qbkvxa+qDcUOouAuseX/23xkFOL jT4Gya/5cUE2zXlwFOl5hlQ7tUazG5WKacSj2xror6VGagu9L/0mz8rjuBwIQJ7g48sz PAyxmjFoZ/xahVY0geFKcSp826T8cx42mYhj67wwThuWZahUcJKQAUX2ZBh7ZUEiE6cI YpzJrduo/ZGchEOKLs71pLssZFrJuCM2SJbSy/ZPpNQH8k4wDPguTswQL673EFuQMH2D BhMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="Eb/ySWxb"; 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 x20-20020a634a14000000b00408a759223fsi1264787pga.776.2022.06.23.21.21.43; Thu, 23 Jun 2022 21:21:55 -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="Eb/ySWxb"; 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 S230165AbiFXEM6 (ORCPT + 99 others); Fri, 24 Jun 2022 00:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiFXEM5 (ORCPT ); Fri, 24 Jun 2022 00:12:57 -0400 Received: from mail-m974.mail.163.com (mail-m974.mail.163.com [123.126.97.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B877668089; Thu, 23 Jun 2022 21:12: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=E5epV JPg/t9YUTy8EYdJ5qpvHm/ag92IRP9C9ezExQ8=; b=Eb/ySWxb4Bs7FHrHGaqRK 9ppG6dY+Lv+E02icvWdeAVVfLpMCGn6h0DqMR7r+lwOkGPmk6/F5e+LLzomKwZxj or94OTFszkqwJRers8wF/4eOXz/bW/eCZelH231VX8XeobUVBNKNlb5tDlD6su61 Og3fKi/CkJdiR2hvp8AVhQ= Received: from localhost.localdomain (unknown [123.112.69.106]) by smtp4 (Coremail) with SMTP id HNxpCgDn7uejObViIy4HLA--.29322S4; Fri, 24 Jun 2022 12:12:28 +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 memory leak in bnx2x_tpa_stop() Date: Fri, 24 Jun 2022 12:12:17 +0800 Message-Id: <20220624041217.1805512-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgDn7uejObViIy4HLA--.29322S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFy7ZF4rtF1kWryxWFWrAFb_yoWkGwcEgw n8Zr13Jr4DG39Fy34jkr4aq343tF90qrn3uFyagrZagr1DJr1UG3Wv9Fn5Xw17Wr48JFnx Gryaqa4YvwnxKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRiYLvtUUUUU== X-Originating-IP: [123.112.69.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiFQwqjF5mLalVGwAAsN X-Spam-Status: No, score=-1.9 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, T_SCC_BODY_TEXT_LINE 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 some errors occur. But when "pad + len > fp->rx_buf_size" is true, bnx2x_tpa_stop() returns without releasing the new_data, which leads to a memory leak. We should free the new_data with bnx2x_frag_free() when "pad + len > fp->rx_buf_size" is true. 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 5729a5ab059d..4cbd3ba5acb9 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