From patchwork Wed Oct 19 08:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp247736wrs; Wed, 19 Oct 2022 03:41:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DZimWcLc/aGSTdoVv7fXlRa+pIYGS4fNhZGUy962fPffv6LFB8ean5juuTbPNtnL/91kL X-Received: by 2002:a17:907:6087:b0:78d:ee99:a06a with SMTP id ht7-20020a170907608700b0078dee99a06amr6191253ejc.52.1666176101458; Wed, 19 Oct 2022 03:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176101; cv=none; d=google.com; s=arc-20160816; b=JrVMfy8ZdVbhnfKeLnXJiB/IGUi7oVs/ISoYCTiAERXirrbDwgTq4AyU/Ig3lgfKxT g5YQaAY2TFxkwBzC7DQY12tm0kaPbcHpplvepv7vV6WdsbJllGm9nXO4zln8oP5wBLur 7Plkgr45kC2HwONJvVrmsS43IHuU0nzSaMAKoMKBtYwsMYFiFNjIkqRswvke7HpcrJON SDeZI0aw91PINlxqCMX+EP+P9ihFQrjAiez00kdh642GqMarIm+yzTDME017b3oG4huv 4mfOd4d1sre+2AeuOEbmLxGr6zxd8NNqvU6PSFVLyjqCyh78j8H/cXkhAd3XP2KJcDIi dvkA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FR9mua4Ku8Z6Wc92MSeDb1Z7Qx+86KosRnQTZCN+1hQ=; b=UZiiLsK+EDh0XKA7ujlFe0K6J9hL2GDTI9dxu/t3CMQkSyjvn/W66QzJG0Cp7dLZND SvP86Fli28Jo1J7rGRN7Nk8IqttO6sbLaLfn2Vq1zXCoisiO22OgwOdsCVCrtMxQZopn EUhqutqCOS/95BLW6FXxkCJFJ82co1Z5zc/kha5DNprZdtE1/jbJXQpc2QC00f6gvaV1 pqZ5TwLB9TJc3sUNCZ8F0zlReBWApuxJ2elhVulSP/MQz88dNfhpkSkMUfjIncwyonKL 3bUrAnmw9/gOlPjzfJDu1YI161bQ7WO8Wvdy/DcLn6M7T5eldkBhrs5q9pb64f2+3MWU IpfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fGJajGsi; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go9-20020a1709070d8900b007879f5efba7si11499841ejc.872.2022.10.19.03.41.16; Wed, 19 Oct 2022 03:41:41 -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=@linuxfoundation.org header.s=korg header.b=fGJajGsi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbiJSKkg (ORCPT + 99 others); Wed, 19 Oct 2022 06:40:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231846AbiJSKjt (ORCPT ); Wed, 19 Oct 2022 06:39:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA4A9157477; Wed, 19 Oct 2022 03:18:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC3D0B823BD; Wed, 19 Oct 2022 08:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 239BAC433D7; Wed, 19 Oct 2022 08:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169653; bh=7go1yIvRjCUaDnh/t/n91CkD5U8iI4PuQcrNJySH2nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGJajGsie3uqGMLMhq2tuKo3V9xi7kmEKSjtaC6y24KvmCXVZSPKJbXLBXOrbSbVj 4XP2Vv6z/vXNJh/o+sKaaVwZNm/qHmmPwsGfh5LdZX9zfFQSH/8LyZVOrzxK4UkTHv sjpsRoG3s77U4xuCyQvQMVPbkBSVTo3zW9S4mOQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianglei Nie , "David S. Miller" , Sasha Levin Subject: [PATCH 6.0 340/862] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Wed, 19 Oct 2022 10:27:07 +0200 Message-Id: <20221019083305.081784871@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112271727555549?= X-GMAIL-MSGID: =?utf-8?q?1747112271727555549?= From: Jianglei Nie [ Upstream commit b43f9acbb8942b05252be83ac25a81cec70cc192 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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