From patchwork Mon Oct 24 11:30:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp403762wru; Mon, 24 Oct 2022 04:53:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Q0LddZNjBIHMoF07b8KIZ0cU85Gjw7ZP159ZxK2VxTqp0f4Ib6JiVpQOLGEpHlU9CUU/O X-Received: by 2002:a17:90b:4ac1:b0:20a:de32:3650 with SMTP id mh1-20020a17090b4ac100b0020ade323650mr72375185pjb.142.1666612384758; Mon, 24 Oct 2022 04:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612384; cv=none; d=google.com; s=arc-20160816; b=FHHk6hv9vVsNgpJ67Bf/B2eC1hSpvKjgsncLe/CZ01wjl41eXq6ySJTZM1kMYdbdX3 a0apBG8rSMiH62bwmX5ORTwbCtbqbgCI/bpHzqZGEsxtUficd1KAAfU/IILMWAjhIen3 qQ171PqzdB1GOIlE16v+EktVE5vfw4v5sxLIv/ugImvJAQ89brWzxtpuMTTF7p4BuxuW i4xEpilI3iEfAnovAY2pyVUR7KdbLrqpaZQf8fC7gWc2ZfvlECFxtIY3serou3l/8zev 12gR1tIaWq6b4QgNKzt+GtUg9NAVo0EVK6fxiGY+UHd8m0QKmIKooFTzi+YxUJG3ttaV +3EA== 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=dWVHjvEuc9j+T3D7oeXi7KXDPT+StQOcMW2g+lAAoSU=; b=ouBSKtNQqLEZZuQfjwKtA4iGfzacs5YGxKVW+q277BWMnN1P1jHO4Pv75byXqF1q7X 7qKFTKA6E31KlpCFGk2sll5BYfPUwZxkI/xz5QqUFD/fd7Lvv/QRgAERDHgKXl7zU730 kPBzJ0vy/hV7I9iSiAP4DwBf+5lF63zk5kvE+aXB8iU22XDdllbpfaNMbvQKOkZyT1ya ScjRkzYBmSkzg+H9eNb5HvVXk0USnOYJ1yT6gZtJasTNK06Avv6+L9ZIgLnk9EIq74mv R87R/RyPx6IfzVP/bARo1U7N53CQCZb8jOsHg17vdprvyhwN7F6v01VFKUMShKla0qL9 G3cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NvhLSXd2; 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 z14-20020aa7948e000000b0056bb75c96d6si4832666pfk.227.2022.10.24.04.52.52; Mon, 24 Oct 2022 04:53:04 -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=NvhLSXd2; 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 S231956AbiJXLwU (ORCPT + 99 others); Mon, 24 Oct 2022 07:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbiJXLuq (ORCPT ); Mon, 24 Oct 2022 07:50:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B2122650; Mon, 24 Oct 2022 04:44:29 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 16FA6612B2; Mon, 24 Oct 2022 11:41:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23935C433D6; Mon, 24 Oct 2022 11:41:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611697; bh=urVshrq1xpz6FUZBSiBKF+RgEbQE/zAnNEppqo9COak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NvhLSXd2dHNQCPDPMUYW9IOmkKlMAsYKpsAqA4FjcMtJg/H4COVDsAJrqZVB3TVV6 syAXvNAMFSbe30SfrvfFOZhz0sqfZGG9AdOrAln7175BG9CAprvxAO+aoeh4MQjt2N Xy/ZhHpCepDIra3s7K6eiISNHE4ZHQbG+uSakED4= 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 4.9 076/159] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Mon, 24 Oct 2022 13:30:30 +0200 Message-Id: <20221024112952.209197866@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747569747631003593?= X-GMAIL-MSGID: =?utf-8?q?1747569747631003593?= 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 9d7f491931ce..36108b26d804 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -792,6 +792,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