From patchwork Mon Oct 24 11:30:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434356wru; Mon, 24 Oct 2022 05:52:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nZcRO7akJFUKWK5cXrHFeMo7NmKyHEGe8aAA9Qcq0wIENogU4w3pQCsxt46tJ8EFbU4Qt X-Received: by 2002:a17:907:7fa9:b0:791:a5c2:e25 with SMTP id qk41-20020a1709077fa900b00791a5c20e25mr24573828ejc.444.1666615922025; Mon, 24 Oct 2022 05:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615922; cv=none; d=google.com; s=arc-20160816; b=SwdscZxprwUet+xvUhum3KIA9ScNoXk7eAwRMTy5HTRV8E8Xjxp/+vfoOTtvrHGUkn 9KfKTefoQkaiI78ISvnJZ495eHn0onz/5MTaHN6sPoZnQaHgYxb/YME+Md+RO7RiNjST lELgMKIk+RmR4wOBOY6VwAVQVTTjvm3I8xbaHc+s0F+yNUXm7RAThy5DEumTFxX5YICA zi4hBt6N+DPjC+fYgFukbhPBcWvF3zk7z3kNvMGasSJxRqh6rvJJfHEEN56fsey2uaMY KIuvkr48Xz27kD/Pe6XnD3qL6VAYoD1OfZd0/KQZmbvd1HOT8OFoJOmCY06tBzA+nLaV bSrg== 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=IqxG8sXS6MuGk93/tZyoLfgJ35VTG9M/+t4GrLueqr4=; b=wP+qM9qfMKpsnmwdQ/HNXA5NMW7MRtgkWIZum6uBbKnK2Ubj0bQO2GA9U19+azqwq3 vCBTebczth7oOD1qgEyda4o9gjxUyBwEZBJjDjz06P9e/NHe8wtseNbjlH0q0OMu+2IN F3hGH0eywFf2Nv/9jaEy/0xlGdvN7M+SflNfQiaTvhwR7Edy8t2/FUCRIJXlaOFLHSMA LjOTrnjtYGXCo9cz/fLD/38nPbm0qlTUujMT+xNC/Q9XuNTTKOGNaBj6v1/U8uPyV1jo wqREi7IZmNNv4fUBtDhuaq2sThKzSA31k2gBPxjGfsp2U1sE5dNaAVJRf78e4mbMWGKC 9AdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZYeMa8Cj; 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 dn20-20020a17090794d400b007123952b00dsi27856152ejc.100.2022.10.24.05.51.37; Mon, 24 Oct 2022 05:52:02 -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=ZYeMa8Cj; 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 S234288AbiJXMsJ (ORCPT + 99 others); Mon, 24 Oct 2022 08:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbiJXMnm (ORCPT ); Mon, 24 Oct 2022 08:43:42 -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 E1B2F6F26C; Mon, 24 Oct 2022 05:08:59 -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 5069C612E9; Mon, 24 Oct 2022 11:58:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6208CC433C1; Mon, 24 Oct 2022 11:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612711; bh=2DLMFDvTjxIF3yJGEqdfltqyhOlUkWuzddtXO9fj3Yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZYeMa8CjquGVjIVXX4f+hZxB7jewBJ98xpUwAlLXIpwHftXOwmt3hYFR7V7xlPcoR US2zBzY/u1sxPbil1NJg4O5mgqpAoR43ZYPbDKRI+xGQ8SKVIPIDoCZVZxnQ4xJDjF 106w+gjSfVcXxGMAW21WF7ZlYA4T7xAUV8iBRPkI= 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.19 091/229] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Mon, 24 Oct 2022 13:30:10 +0200 Message-Id: <20221024113001.996309598@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747573456701725266?= X-GMAIL-MSGID: =?utf-8?q?1747573456701725266?= 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 2610acf9ac36..53b1b05f905e 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