Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1488925rwb; Wed, 28 Sep 2022 20:15:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5rC+F+px6o2QBDRhn5kL4A2NaIeGaixrADQsEx98BrfQ+kjOIcW/OFDJtYxv7eq9ITSsO5 X-Received: by 2002:a17:90a:3808:b0:205:dd00:f886 with SMTP id w8-20020a17090a380800b00205dd00f886mr12099252pjb.38.1664421340705; Wed, 28 Sep 2022 20:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664421340; cv=none; d=google.com; s=arc-20160816; b=eIKyOXr0W3jLCca/fLBWAHO8a6x/l7zc8Z4g/LdpyLsTQfoqddQ1HHo/IvM21tE0Gz /kFS3dAv8ljgzkRcNidQqi7fm9AhXjGrHUkeXD0tQxic/hhmqdgQ0HiKi13MJVwyvBAL 5kfRirXV+RfbrUxySV485v3uT+QgFRJZy3aJDuNrxQ0pH0sZix9vnhxjINu0v3kIv56q 0WS3ar39GsmS3VhNkVyzSGmGbWe5X+Px3NPUj3tyf6ArV0anRlztlrJZ+NeBBihWMl3v cKTWr3A6tsJlnF74SzsoR9+IyVmnbmhci/tcEa6MCyD7QeiZ0vBZHW5ecnJIh3pt647J BrIQ== 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=bjNhmCM4v+jDZRiUHBiePOPQW64zNvuCPbudERf+mCY=; b=lOQ7yGMA10EZKYrp+jGbGZcqvz8H+EX5VroBb3YdJGPky2JxcMyQPqGb9iV80Cd0ho kl7TP3Kjy+VYTaZMmPJ6Tl8CNG9j26QlLDeUEUreH+RWLqIuxDrlplM/D01eRcarIT5s O47n3mQVZkMRR46V7XGqqHSkHtm0FnNSOAUbPmtxlEWzhQcpdgro3paePfJVHx9fY/7r dBVn2RYi8qHWwg3l/voTaNtLfpdawsmfS8x/wUKA1TpaAqiWdXymU9C0CkmzmyCV8pFP IGHKyIrfFtrPYstrCGLIOC8FhIVvCb1JoXG5UDVeVMZOmXwfLKnG6i3AJL0OU2wZttVO PIwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=ZxYQ+RPV; 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 b13-20020a170903228d00b001786b70f913si8005144plh.164.2022.09.28.20.15.27; Wed, 28 Sep 2022 20:15:40 -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=ZxYQ+RPV; 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 S234788AbiI2CjB (ORCPT + 99 others); Wed, 28 Sep 2022 22:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234776AbiI2Cia (ORCPT ); Wed, 28 Sep 2022 22:38:30 -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 7DB6F126B50; Wed, 28 Sep 2022 19:38:27 -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=bjNhm CM4v+jDZRiUHBiePOPQW64zNvuCPbudERf+mCY=; b=ZxYQ+RPVx+r/egn+gEGJ8 /rFFVokJ0YRyDc3HyTSqv6xlsIw398QIL+/J/bQEtipbr1BKkbuc7BCfbuWYoclG ZlzU2jh0E5gMXD2qajvJgr5VRJzQPRoBp9tUIR75vjesQrQJgwPJ1pKyl9Cr1Nsz yQmAQCmY00AwdG/Ff8yef0= Received: from localhost.localdomain (unknown [36.112.3.106]) by smtp5 (Coremail) with SMTP id HdxpCgDH4wMCBTVjmtG1gA--.20705S4; Thu, 29 Sep 2022 10:38:02 +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: Thu, 29 Sep 2022 10:37:52 +0800 Message-Id: <20220929023752.5914-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HdxpCgDH4wMCBTVjmtG1gA--.20705S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrKF13CF1rWw17Gry3WF1rZwb_yoWkuFgEgw n8Zw17Jr4DG392kw4jkr45X34ayryqqrn3uFyagrZagryDGr1UG3Wv9Fn3Xw1UWr4UJFn3 Gryaqa4Yvwn3KjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRMsqXDUUUUU== X-Originating-IP: [36.112.3.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbiQw2LjFc7bj7gIQAAs0 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: 07b0f00 ("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