From patchwork Sat Oct 22 07:22:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1094750wrr; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HP38SFqCYYhXsr/+bl/iZiA69R3TUdq6IsidlnsEznP2o5htkQzZBAFc8ZYQoSAcYlDhX X-Received: by 2002:a63:d1b:0:b0:42b:828b:f14a with SMTP id c27-20020a630d1b000000b0042b828bf14amr19889963pgl.235.1666425655394; Sat, 22 Oct 2022 01:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425655; cv=none; d=google.com; s=arc-20160816; b=xj8+sfGtp4yaMOKptf0QHZQ+1moI9UmpLjDfY6TYJwu2sW+ijWKAG+chXA5HnFG07+ QNgXVPQUKRSG4qbYG89lfw8y2+aOMEbdI+AUIuF7L7EzW9rUZJzKbRikBj34P8elLVtR HIgcNKGSYGKEwNpSmZXLL07IT9ka3P1jA+u9Cv4OJpk8nS3wZJ0T2MtvIIZr3wW/UYgl R1SJAs6czWRRWdE8KlHLj9UNijwqFdfrmD6Y+aN5Qo62SWdoNiwSMpnJ6KEbhS5oyjIZ SG/BZ35pp4zcN4SeDblERvPsGwZ4AAXrTXVqg0/4/T1Kqj0SEKZ84YTDBCfirefoQJ+1 RNag== 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=x0hoey/w+Al5u4IT3VAMva/F7XmMt3wcuzpvZk3Eq8c=; b=X2/knQUpQ+zhrHlMHYgo+XWrgDcZdMACQJs+gNl3K24QVbgqtxoa4R/KZT1pNBE6Bs DJ+wr8A1the+xZlynH+mNM+4v5GGfGO8pH3WZKr+RNIEZ8RdQ5EDLm4RLWnB1lrIzGga OzhEexBa5mLnDKeNeKE9V8y98eRuBnvJKtghHa3QSZQeCdRturNc43GORQG70ixUZdzI nii6WuwNeptdfwI9HFFSqim087xuAFiOcID3K7uG1KzL9x7oLaT76RlhpHc1J3f/T8qo CLHozYG6RQZVrH00Pojm98p2ab696QwsBirlxzsqEDJhD50v8Jj9kHvQ7KbEaoRR+n0V 7sUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jXF6PIpi; 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 c6-20020a170902b68600b00174418919a6si25920422pls.513.2022.10.22.01.00.38; Sat, 22 Oct 2022 01:00:55 -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=jXF6PIpi; 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 S232269AbiJVH6m (ORCPT + 99 others); Sat, 22 Oct 2022 03:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbiJVHyE (ORCPT ); Sat, 22 Oct 2022 03:54:04 -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 69176645CE; Sat, 22 Oct 2022 00:47:21 -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 583B060ADC; Sat, 22 Oct 2022 07:47:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A79BC433D7; Sat, 22 Oct 2022 07:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424824; bh=VEZNnwj0nUV+r46mdb30yQGhzT2eyjw9eB3hHB+x73Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXF6PIpizCTdD+bMU0JkC/oqMlOn963O0Xw87fvXxpa6J8fuaLONGCOwBy/ToKgq+ fv5USg0MHPs+U2/JZ+zOQZaB5wLtiq+a5rDiZjTPowgMGOQIQLyu3DC8AJBTA31d2H b+U1uhayMxAB9Ved1o9CUiLTE7+ZiYGD/uoVRqnU= 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.19 289/717] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Sat, 22 Oct 2022 09:22:48 +0200 Message-Id: <20221022072504.604401072@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747373948190869592?= X-GMAIL-MSGID: =?utf-8?q?1747373948190869592?= 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 5729a5ab059d..4cbd3ba5acb9 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