Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp3165339qtb; Mon, 24 Oct 2022 07:12:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47m9i+YZgzfP01rlxrU2e7KPCuNRn2RNd+3Yi7dbezHaurY8+2K3x2leY6PQpWZ45t1MTC X-Received: by 2002:a17:906:5dda:b0:78d:e7d2:7499 with SMTP id p26-20020a1709065dda00b0078de7d27499mr28160303ejv.588.1666620722232; Mon, 24 Oct 2022 07:12:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666620722; cv=none; d=google.com; s=arc-20160816; b=uGZMuUO0ut8g3MPahloL+O6zYxVw1fP3kg38NZPBBiCN6h+dM7UYfu++fHMbXoQtrR 7o9/RkfGJ3hNiBM5tBkQng0cBLQKmE/lKKQ2itaRqOFksbXUzKJf6/MPmOElHJkb1v+V V2oQMq8+Jzka0E6RBqPdwxdX6URGXK9+7PM4VbJ/dZ/WMiOdSLtfgjcSdK6sKQrIOtE8 J7ZPhvfdHHUk+YgOm75NioiONbmBb5wou4lWQ7Eq4I/SpFqblBKMczr1+oehxlEGEq7o kL31Oh61MUYugthMqiCzfZDavVFyFFoHV/T3mA8eal8d4ofKxY5AxIYzrRGNgBP1BX32 p2qw== 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=uvz2uGnkhI/XA/+rL47HaVnw6hiLofWrRrRrAXjdOD0=; b=VEkM+WTxsLNnT4EQ+RhDaLvHlv7NWkx+KGkXeH2XjtoHGH0Icak4npRNjSdfgnWm16 n0lriQOek2MCg3UH0B5F6Iq8p6Kxioe+k6N44yUTCIfqNpS8TizSvpguzYeZs4QXtHOc SEVkaRTIB16KJ26fkpAN+VRafQn2GDqmIuKHRHffetxvxCyOo38ydCxDE/Gs5DEkhroi e7guL+fj1BmAwcIdZnNUyJRDKK7eUwCgAE19SdGkZzA/yUzjcOn0wehVCrpDfd0JB4YA XpUCmNRlFizpk8uDsjpLu9dFSTpGnijvKRIGZXWqzjk+x95MElbN39EQ0nNyhkk0lfdF SsMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dMA79c2t; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hg5-20020a1709072cc500b00780636a4a58si27393326ejc.626.2022.10.24.07.11.36; Mon, 24 Oct 2022 07:12: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=dMA79c2t; 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 S234423AbiJXMfC (ORCPT + 99 others); Mon, 24 Oct 2022 08:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234231AbiJXM3l (ORCPT ); Mon, 24 Oct 2022 08:29:41 -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 96FC023BEC; Mon, 24 Oct 2022 05:03:56 -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 8FEBDB811A3; Mon, 24 Oct 2022 11:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB4AC433D6; Mon, 24 Oct 2022 11:49:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612176; bh=IT+ZuMJ69P+nAjLoBJUvmEOjP20rG6UnYzu9ZDnddCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dMA79c2tYlg2QaDwQm9Pi+Vmwsf8UOaKZoYsNfkDqopQKBNeeHWPTXgb7fry00Yft trAbNCBZBmwlTkio3aO4faqnAvArWa1BCExzUEwSMB3l1K3GXtf5IqYlnsNe1TZdz+ z1SpOrln1S+gCYJlfBHhXknVOymbm0io2zLQlAUM= 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.14 097/210] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Mon, 24 Oct 2022 13:30:14 +0200 Message-Id: <20221024113000.171390852@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 8c111def8185..96478d79243d 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -787,6 +787,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.35.1