From patchwork Mon Oct 24 11:28:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp444901wru; Mon, 24 Oct 2022 06:11:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7B58zNZDtnyBYpEeaiCFSiIsNv7Lv6xXAzTvE0Xzmw39Hhf+g4f2wFAG8sFZ2RvZMHzXPy X-Received: by 2002:a63:1521:0:b0:43c:9566:7a6a with SMTP id v33-20020a631521000000b0043c95667a6amr28230148pgl.339.1666617111798; Mon, 24 Oct 2022 06:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666617111; cv=none; d=google.com; s=arc-20160816; b=oeAzTBn0LiPhWV9kRnDb/TFY1LvklyxNHZd4vWMwACDSZM1vcRRl+Qg4xaR0AVhBZF NDu4OsZM465BDUyTKVABvSIyFr+FDlMX141EHMQYvQ2wAJJSQ2AUzF2HEpBI/Rmu+DDC UV2we86HvHe8/BljJ9IjGwnE0MBiGQ5xM83ukDy/IQEaocRbkwTTO4AtogtSQhQd4i8F 2yhQLwYqGYfjtxQ3HMTc2e/jklxOxB2j239aRsC72AunNi2j58JsWyRq+4u9n9f7jUoS c3fintF5Wonkes2LbZL6fOzJ35eX/sGYPayE71CF/fA0L93NCiAaW0MYUB0/3ZayupSO wrXg== 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=fw8iFZPatKPxg2sFnKktRfdQpQkSO8PILpvSCERDDM0=; b=e3XVkE1S4PeAKsIV4zq3P8Y7W9U8p5F3dQ111jBxPbl0/W7lXIJxfmaUYsy/4MHGGU TXKAbtuEMq7SgDL11VEf2hGLzRWc+/GuqZErmWvMFE7oJ3eE2ITrvpUo69fkLXA/F4Eu SK9FaqILAAAaVb1zqzx/e7l8O7h+8Th07fxbGvnJliaaYZKbqQhoH+4BelkG6xMe6pKw LvXu4HseUOvRLwNmdriIJ/0LJloyTkx5bGtD5/0RUDIZDB2RP9j9CS+KBYZEv9/J9Ens FBoYbC9AAO97QCitugwClrM6gHnnWDPbx0VweWZXdgAM7Ry5iXD4sVbaeC3x45Pa/Y6e E7Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D1XK1Axq; 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 b10-20020a63d30a000000b00446ec91cdd8si38878363pgg.604.2022.10.24.06.11.38; Mon, 24 Oct 2022 06:11:51 -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=D1XK1Axq; 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 S235579AbiJXNLO (ORCPT + 99 others); Mon, 24 Oct 2022 09:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235545AbiJXNI6 (ORCPT ); Mon, 24 Oct 2022 09:08:58 -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 E0A169E6AD; Mon, 24 Oct 2022 05:22:02 -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 77F1D612A1; Mon, 24 Oct 2022 12:21:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86A7AC433C1; Mon, 24 Oct 2022 12:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614113; bh=FDJj57zct8g34Bx1kgQb5O2g5HvH0eUpe2PeLXP760g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1XK1AxqWAL/74Y6kh44AOcAJMUHx0BT5WXJnC6fMASzkWEuqRIXTpK+Y/CTcDHuF 8WOBmhMME7pnstJIvBsWSKlPhP6eebjtV8g6BALZXiQY1iwcGkKKb4tL8Z7Y3A2yLS B7k28MyY7YceLpwkYc3GIAe68K11mZKI9rmxDfV8= 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 5.10 137/390] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Mon, 24 Oct 2022 13:28:54 +0200 Message-Id: <20221024113028.509395386@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747574704682647239?= X-GMAIL-MSGID: =?utf-8?q?1747574704682647239?= 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 198e041d8410..4f669e7c7558 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -788,6 +788,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