Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5300097rwb; Wed, 7 Sep 2022 00:02:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5PePC4PGmxH7hsCQTGd2kY4ztuGPkZH3PNMHsQ07SGpHcNeuXT1JHMpxMQdYJaV56bC9UC X-Received: by 2002:a17:902:c94d:b0:16d:c10a:650e with SMTP id i13-20020a170902c94d00b0016dc10a650emr2430318pla.29.1662534159892; Wed, 07 Sep 2022 00:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662534159; cv=none; d=google.com; s=arc-20160816; b=0VyEf8ixx2Jlqzc4E582J+YYJ5LnqOEz3+xg0aE/esExwC8steEwYKGm8X06sRYMU2 0R+l8OsJQNxvceNeM5L8wwUXpqcsenj+9hdepDWAbOSbAoOsIATy4a6iEbJwmXxoHsbI OxJ5G5f0sugKjOfsgLXsijy8rgnu8s4Py245GfLVjSCBVUDhsMdYsxxfDHUY+uChpDuK FKMQGc2mKA/Zu0+driZJiPUGitEoMgKr/PJAlRpvz8SgWNWiw4r14eJdd7nCcCeaa9g7 SKvVBuZpZFKVenf0Ni9EjwwRRAIgoezM5+YhpRkZNIWY8XMc79UXXxs6OpZSpFXi/+V4 lchg== 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=X3lrt93nIs2ExWkz5BJeKbh2vPXhTHhjwRs/Ic1JO0k=; b=AfAFiqPiC6SZshFiKNxD889x7l2B4D5YKGvHLXGQVBzS+Y9TZZqBp7aI9bMWbdoD8I d25KPca9wCcChuIbQuOymO9mFmL1OXFfy3j3F2BrV1qPAUIPTe0qTQLaTKTIn7Zm0KKO 3W5NvIBK5TJWxUgIbksTskQ8wTXkVxzrCEhNKB15YHqnMJJIjwWDfuSBTXqTff1q9Kdb dW9RyqtnPvwQdRehS7xDOgUViy+1MnPIomYg+oMTjzguVs5k34yT3X3tc6X1nQlCErSX grmWDIQ2cRmbRiGfKl06KuJfNyPK1+Yqrv5NtC28be6pPthEUCN89wnp/om0bcHr9qyt 8PIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=SKbogZSK; 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 e9-20020a170902ef4900b0017452480670si15519148plx.228.2022.09.07.00.02.28; Wed, 07 Sep 2022 00:02:39 -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=SKbogZSK; 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 S229894AbiIGGwX (ORCPT + 99 others); Wed, 7 Sep 2022 02:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbiIGGwW (ORCPT ); Wed, 7 Sep 2022 02:52:22 -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 5C4401CFCB; Tue, 6 Sep 2022 23:52:16 -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=X3lrt 93nIs2ExWkz5BJeKbh2vPXhTHhjwRs/Ic1JO0k=; b=SKbogZSKr8kZld7SmnyOV oKJzDXprGRh2c+RW5yQc8iQvfU7kSsKVwlU1ItF7qa2peuQku3BHkMDA/HH13ixB 3fkr03lB3Mf5yXgXo2QPwxsGP8u0hrzOnYXhll/c7YiURIEwkhg5vzdRZ5TslLnv mIJCM+Bnv663esXF7kOH84= Received: from localhost.localdomain (unknown [36.112.3.164]) by smtp4 (Coremail) with SMTP id HNxpCgCnxs54PxhjRjvoaw--.21843S4; Wed, 07 Sep 2022 14:51:45 +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: Wed, 7 Sep 2022 14:51:28 +0800 Message-Id: <20220907065128.55190-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgCnxs54PxhjRjvoaw--.21843S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF13CF1rWw17Gry3WF1rZwb_yoWkXrbEgw n8Zw17Jr4DG392k3yjkr4aq34ayFyqqrn3uFyagrZagryDGr1UG3Wv9Fn3Xw17Wr4UJFnx Gryaqa4YvwnxKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRM8nYUUUUUU== X-Originating-IP: [36.112.3.164] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/xtbB0QF1jFzICmnm4QAAsZ 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 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. 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