Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2606585rdh; Mon, 30 Oct 2023 02:17:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzg3uW7wVm8mBFAQlYnJt/9Lq+9Ru9+DvKkmIaLitw2owXi4cFNSzeNIk3kkXXzX5n0i21 X-Received: by 2002:a05:6808:8e1:b0:3b2:dad1:72d3 with SMTP id d1-20020a05680808e100b003b2dad172d3mr10998395oic.50.1698657455364; Mon, 30 Oct 2023 02:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698657455; cv=none; d=google.com; s=arc-20160816; b=DjBGL9SYmMashEqnucStx2o4TlLRMjFNc6rISmdz91ZPZAE//usYbHbRl66xDfRzXI k0U+RAvWhVV3HkV+7e5WibznhZBTRFgvIb85m1BwC+EH9hvWUFZOOloj5GsR8qGuquCX qcM42kUHWg3tASzWBPkHIcuZ68bOUVsyQaWJXnVMZOrHRZPBR/Ho1sxgHA93OGX49xor ISoKFuTb5Z6n0uvjU2Bz1un41zXla9jvAd6ZSCS8vLokBb1BLAKWDIJLvsjWjYJoqKuj Uc2dUiWcdEGAIIqLZX4QLJqifA36oeaSdHF86NBfK0pQVWWS1CLAo6spQMp0BKQBMwqF Ewug== 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 :message-id:date:subject:cc:to:from; bh=AqxqOKUDwxv7qAzDcxw+VVun8W3Pfp3InfEssGeDre4=; fh=UZKLR/EjA1wlnbl7bRRMDK+4sKZU1mLFzNW1MHcRd8E=; b=ujTJkGGoiy0url38l8SMSbE//dFu7iRE7nxPcDbFenEhG9Mmd2AcS2EC5glNL8BnHC 0Y9pDYtFGYf7ZOsKGYLvXJAKmvUpYTHkeFFS+0n2YjmnJHDR76rvv+w1YsXo6NFK8Sls KhL5gyHNYV6NDEkTbdZlY15roA35v2pQyWpMiMBZFE9AK5TBr5uONmb0fTz1lDPWlYKO r91Q6AHffn4wNPVRI4MfEFbZvr3Qntg8JLiCXCVe/HGPf+c2YExZIwPPA6m14pxpJhOA wpINiolsxhgPm3mA1JUd5hKHGQ+ffNNOtSyGBkt++S7YDjLED2bDLx2ZQfAqrfzmkjpE M95g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id b26-20020a6567da000000b005b98cb7b469si1547833pgs.219.2023.10.30.02.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2DA85809C907; Mon, 30 Oct 2023 02:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232283AbjJ3JRG (ORCPT + 99 others); Mon, 30 Oct 2023 05:17:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjJ3JRF (ORCPT ); Mon, 30 Oct 2023 05:17:05 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B81C6B7; Mon, 30 Oct 2023 02:17:02 -0700 (PDT) Received: from kwepemm000007.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SJncD6JpBzVlpb; Mon, 30 Oct 2023 17:13:00 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 30 Oct 2023 17:16:58 +0800 From: Jijie Shao To: , , , , , , CC: , , , , , , Subject: [PATCH net] net: page_pool: add missing free_percpu when page_pool_init fail Date: Mon, 30 Oct 2023 17:12:56 +0800 Message-ID: <20231030091256.2915394-1-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000007.china.huawei.com (7.193.23.189) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 30 Oct 2023 02:17:33 -0700 (PDT) From: Jian Shen When ptr_ring_init() returns failure in page_pool_init(), free_percpu() is not called to free pool->recycle_stats, which may cause memory leak. Fixes: ad6fa1e1ab1b ("page_pool: Add recycle stats") Signed-off-by: Jian Shen Signed-off-by: Jijie Shao --- net/core/page_pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 77cb75e63aca..31f923e7b5c4 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -221,8 +221,12 @@ static int page_pool_init(struct page_pool *pool, return -ENOMEM; #endif - if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0) + if (ptr_ring_init(&pool->ring, ring_qsize, GFP_KERNEL) < 0) { +#ifdef CONFIG_PAGE_POOL_STATS + free_percpu(pool->recycle_stats); +#endif return -ENOMEM; + } atomic_set(&pool->pages_state_release_cnt, 0); -- 2.30.0