Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3765912pxt; Tue, 10 Aug 2021 10:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnXCN3zZcgGAktWt+ewFqG4AMrX+0YQtUDprd5osa6faPrm2k6tf2q6ho8FvBu6jShTAVf X-Received: by 2002:aa7:d404:: with SMTP id z4mr6189869edq.255.1628617730151; Tue, 10 Aug 2021 10:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617730; cv=none; d=google.com; s=arc-20160816; b=ok6OXnppGYmrXxoPN/AiAizTvRAQH7Bsdt9vKzod59ajFkbbJAVsVBHoBis14PAutT jIn4/it54Ao6/RqMII3i/uJySZfLGqZ5TkWARaPzfIAnlQd3WxtIwnk+fD1JVWZyBO4m et0rJW4zfYyQYP0DuUsA/d6aC8nBmLKtf9jnE6bzf3pAuyhhCEco7LMKe1vHuAsMtxC/ LJRc9IuJvSha0NVFiuWx1IdHp/KSA7jV8UB1+a7Pmmo3T0tmAG6DldHoi97jqrVVfaGe BFpAYQ1SbsDAeAPMjea1ud/ueOwovhXiRvszruhoCKjYEovmAXKMTg7vGK/xWw4R0L2p jYAQ== 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=Vs+dfnas4IwPIg61syd9vi661T7tgNftIu4RDT4ogag=; b=ff5RSjpZAiZnC7pLdZvBMmB2tMKQZ6WMmXFkirkIg2eB4d01JyaAIY8SmLXR64Mls3 3cCBdgHsD56VcSHw4SyP1gQQXGqwa2GQD95QwGl0ITkA6fdCiRqxweGx5CIMG2WJ6WmI a0UIQLsdnGgOugsi8zBGzbcOQderBNoaKWLls9jmhSLVmfNuf645xMHxmDLczQck/STL mVGPJJnSC2jikYbCd+GH/zFxyGTxYv632jQx/E8Rgw5O1VHFj/wo8dzxiMgZfjuMmND9 tOaVPXIdBj1PU2t9byA7r3KOL8zFIqtWAlzcRDEbdvwIxVr8n6hTObbE09arNEhR1GLg ZaLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gncX53wH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si5896720edt.426.2021.08.10.10.48.26; Tue, 10 Aug 2021 10:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gncX53wH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232709AbhHJRpO (ORCPT + 99 others); Tue, 10 Aug 2021 13:45:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:38840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233975AbhHJRlH (ORCPT ); Tue, 10 Aug 2021 13:41:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B15DC611C5; Tue, 10 Aug 2021 17:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617097; bh=4N9F4XwHqssl3coRKsDZj6kfcnqot9nOZGW3exOX8oM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gncX53wHrDKdb21vEsc9fAnAJ/pa4rTz80lbXnS/NLqgYxcuwRYLvMUsTkwr5QRAy O0v0pNRJ/c147xzfzQrb+Hj6Gv+QKw7pymUJOPhBZJy+9vHOY7F953YbjtibAgzrD1 IgwDFJnxe1Ns+u/cO2Rc5HvfIcKd0fmLaovkaM7o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joshua Kinard , Huang Pei , Thomas Bogendoerfer , Sasha Levin Subject: [PATCH 5.10 044/135] MIPS: check return value of pgtable_pmd_page_ctor Date: Tue, 10 Aug 2021 19:29:38 +0200 Message-Id: <20210810172957.188573777@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Huang Pei [ Upstream commit 6aa32467299e9e12280a6aec9dbc21bf2db830b0 ] +. According to Documentation/vm/split_page_table_lock, handle failure of pgtable_pmd_page_ctor +. Use GFP_KERNEL_ACCOUNT instead of GFP_KERNEL|__GFP_ACCOUNT +. Adjust coding style Fixes: ed914d48b6a1 ("MIPS: add PMD table accounting into MIPS') Reported-by: Joshua Kinard Signed-off-by: Huang Pei Reviewed-by: Joshua Kinard Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/include/asm/pgalloc.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index d0cf997b4ba8..139b4050259f 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -59,15 +59,20 @@ do { \ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { - pmd_t *pmd = NULL; + pmd_t *pmd; struct page *pg; - pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER); - if (pg) { - pgtable_pmd_page_ctor(pg); - pmd = (pmd_t *)page_address(pg); - pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); + pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER); + if (!pg) + return NULL; + + if (!pgtable_pmd_page_ctor(pg)) { + __free_pages(pg, PMD_ORDER); + return NULL; } + + pmd = (pmd_t *)page_address(pg); + pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table); return pmd; } -- 2.30.2