From patchwork Mon Oct 24 11:29: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: 8940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp435134wru; Mon, 24 Oct 2022 05:53:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64WxXiNQnw+LMZrvcbAQA5/WllEboxt1Kn+MZwBpxBDgv4UoX8g0kWhKLI4JJPank+BfES X-Received: by 2002:a17:907:d89:b0:7a8:d67d:87d3 with SMTP id go9-20020a1709070d8900b007a8d67d87d3mr3278034ejc.364.1666616021156; Mon, 24 Oct 2022 05:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616021; cv=none; d=google.com; s=arc-20160816; b=iaBDDVGVNxHe3rUiXTRTv5yv0WUji6+W0pUknjfF0ihz6hcB+HIVlQg3jP+IjVSQwD 4mq29C+uU0LIeeH2cuHJEJDyHj9BspCL0Zd8vQbc+cTW4y7Kw5zmGAkW6DLtTNXurYvK TR7NcaQnIeKeHH95JQVk/iqvXEYTl2xBANoLrFE9/FQUkgeOC9hOET00AAj6dFXnBupJ yXOlaA/hg+wLSz+34dI9egqdmoyFYdK0tXje7QRJe/guBBqfEwD7mOId0uOCoiLO4B/V MtycXBTd60gicLQaK9x3o30P9Swine5p5UyaebPoHOvu21Cfij7UALwuPpLZVcn39AQQ BBuQ== 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=Oh0IziQZhKeYNlfpfRn33dTTMuill2SHd9n/uuReXOk=; b=Y1kFYH2aIu4GW1aFmIc+CtaDYLdcj5z7iNSIsXCtypbPfAPkbh+uKcY7eYZaAxuYi3 Y1Q5ArPtOI99ez5twaf2PVBwondYcBR5FNBckGETEJVm6WeMpR3vz007SaQHPSk0pRT7 dfUn1QSU03TPMRoBaDfY5d1m8otC8idTn1h+q8D36OUZqW6NkAMSVpWH+dtfeFXO54Lh ta+MX9L5Pk49PzKGtQnYiZi9JejRYjDkia0egPR8PBawyPxLCkziuQrGTaMtGs+zf7pB +beDviFiXKhRvwjY+4972tCpxBFII7xxh/xZJbln4uW3hlR3bCrQYRfuVtl9yqa9xcQb DbBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QbUwv6/G"; 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 qf22-20020a1709077f1600b0073fc8e72882si27068573ejc.28.2022.10.24.05.53.17; Mon, 24 Oct 2022 05:53:41 -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="QbUwv6/G"; 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 S230043AbiJXMw1 (ORCPT + 99 others); Mon, 24 Oct 2022 08:52:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235521AbiJXMri (ORCPT ); Mon, 24 Oct 2022 08:47:38 -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 DDA9480510; Mon, 24 Oct 2022 05:12:23 -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 3C152612E3; Mon, 24 Oct 2022 12:08:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AF05C433D6; Mon, 24 Oct 2022 12:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613300; bh=dki//+ul7bXiMbekV2qwewjmJI5EqUjlJZpavHCL+Kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QbUwv6/GXKs9mRjur+ltVDKPf+MQtdXZv9xyv6LvX/hkH/rDURfe/cgAgoMS0kbKB sOVMMlHd11kj6VEK5wEwG+qnd7lN/MmvoHHHD4fgOTMDYEF2WF3bm+GSDPeGB80rCK 7YTy+2JqZeCL/3LEfEvdzijU9jOpaNG+7UrKVCFc= 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.4 084/255] bnx2x: fix potential memory leak in bnx2x_tpa_stop() Date: Mon, 24 Oct 2022 13:29:54 +0200 Message-Id: <20221024113005.303398845@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573561107519738?= X-GMAIL-MSGID: =?utf-8?q?1747573561107519738?= 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 9af8afd7ae89..d8e13ee0601f 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