Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4082259ybi; Mon, 29 Jul 2019 18:52:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCUhvU29JZsD6T1JJO2j/HQ4Y5GzqfhTVOvo58VbMfpYScqCvlisMGZ35VF18WUy9EA9Je X-Received: by 2002:a17:902:b789:: with SMTP id e9mr109972694pls.294.1564451554348; Mon, 29 Jul 2019 18:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564451554; cv=none; d=google.com; s=arc-20160816; b=nJJAS9dqnPG4Oo2UMzre75MWlDIc2oFCm0c/Ss17Ux1MELN5mfqhtNEgpGHxjsjBFF qC1TujFgM/g3tusxDcdHKCLF7kdvbcyrHJbJa5lk5QM1OnZJ8X7qM6vOx36b0aVOL8fY TII0h6g+XQkBK6UNYmGBvg2NjfZNV80Bw2Rx+0GScaIGX6XUk7IKVjI41jqfWrR9Wu05 dNMOEChWn+NTleZH6ZqF6caxt2yZNSTxJ5D0D6TCTzGnH6rbFjjRc5/eoj2FDbhUS9k5 F735mECLoZaDQOuyfYgzInPQkyWEzImL6qiMZ6YH9IHcHbc5V5o++RgWsdkkKc7wNnn/ 0RUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ed82aehcsVxRR8YS4B8sMULKyKuSLxMM4sOt07aUUDo=; b=TlDUfDZS051ikSFG2uehsG0w6mtfk8ZZZFxqQErbgwdcr3u99v7tY9FLLYjNlNgX9e fx2boMYtwTajdrFj7ANM5WShUWu0L8QQD1LxV9jRA69sebNg5q4iE37z3OMgTnYZJyuA dEW9JglJ7q8X/fO78jn+aCWZ7rRKG0/UWbc5Y78KHP03eJvLl5YGpZ2YiWYQsRPc5mKm VGnbJKDdMaeHXf0ogm8tcbK2m1PaWvkqmPNLZR/WTYD8s/bIOG2umaLWLJHfae8uI0Gl ftIVh8EvKefiIVeMeSgue5Mfq5tx20VS59MTKf63TGOjG/x/sHIfxfoN31tF22r0ETQQ /kGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jSv+hbUi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si30516354pgj.347.2019.07.29.18.52.19; Mon, 29 Jul 2019 18:52:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jSv+hbUi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389438AbfG2Tl6 (ORCPT + 99 others); Mon, 29 Jul 2019 15:41:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:57518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388566AbfG2Tl5 (ORCPT ); Mon, 29 Jul 2019 15:41:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C83CB2054F; Mon, 29 Jul 2019 19:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429316; bh=mrPfb4yn5qmbsy+jrQ54Euyf0XfhyDXl+Ju9S5MQqmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jSv+hbUitAT5C6QCp9fmUAWvjyHdCojAOL620B7LkIQBi5e3RN06dDa2iurm6xzeE 8+OzcO9xpeT7DQjbgXi2gBQZJy8UoajqzlYI2RmblaRmME6jCnA4hCHA2/aDWBPlVI f32tG/FsCgJpq5ld7CaGQ0xhEOd6NbvaWk6uoMo0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 059/113] powerpc/mm: Handle page table allocation failures Date: Mon, 29 Jul 2019 21:22:26 +0200 Message-Id: <20190729190709.585562359@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 2230ebf6e6dd0b7751e2921b40f6cfe34f09bb16 ] This fixes kernel crash that arises due to not handling page table allocation failures while allocating hugetlb page table. Fixes: e2b3d202d1db ("powerpc: Switch 16GB and 16MB explicit hugepages to a different page table format") Signed-off-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/hugetlbpage.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index 7296a42eb62e..cef0b7ee1024 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -150,6 +150,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz } else { pdshift = PUD_SHIFT; pu = pud_alloc(mm, pg, addr); + if (!pu) + return NULL; if (pshift == PUD_SHIFT) return (pte_t *)pu; else if (pshift > PMD_SHIFT) { @@ -158,6 +160,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz } else { pdshift = PMD_SHIFT; pm = pmd_alloc(mm, pu, addr); + if (!pm) + return NULL; if (pshift == PMD_SHIFT) /* 16MB hugepage */ return (pte_t *)pm; @@ -174,12 +178,16 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr, unsigned long sz } else { pdshift = PUD_SHIFT; pu = pud_alloc(mm, pg, addr); + if (!pu) + return NULL; if (pshift >= PUD_SHIFT) { ptl = pud_lockptr(mm, pu); hpdp = (hugepd_t *)pu; } else { pdshift = PMD_SHIFT; pm = pmd_alloc(mm, pu, addr); + if (!pm) + return NULL; ptl = pmd_lockptr(mm, pm); hpdp = (hugepd_t *)pm; } -- 2.20.1