Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131937ybi; Thu, 18 Jul 2019 21:39:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk5nAUhE1lUfrNT34O+iBgTCLrgam2azBuftWJF2boCS4YWclenYY/N6KuUn5J9x0CDMkS X-Received: by 2002:a17:902:7c05:: with SMTP id x5mr54918342pll.321.1563511154021; Thu, 18 Jul 2019 21:39:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511154; cv=none; d=google.com; s=arc-20160816; b=ffdcp+q1kG+X64mIzowQAL21W70J98QkELZOUNFGqPNdF+Z1dc7mxyD5VcpUSwqNzQ qHtYiLZy6EXbu+abmFpjMIezh3AJhi9nxxcTLS7df6Sf14Ut7gS6Fm5aS40OzCKccluS N8pr0u4gUqdT9Dd8Hch+1dTonhnM98ivrO0om2tQIz51vZRtbLdbCGAZgrg9A9qoU9c8 iIfQItqyWnL+JW3lSyzVHfvwUJPXm2XcNUfViKhYZfbcncpm1Asu/p5CggD4tZI0IIQM cOrusukM2Qzx9aLY7IunR8sw655kLRstbsFsl1TS0Ghcv1jcFW/yd7HJ6W6vdtMnmxNn C8gQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UeKi2WtXqecJlDfa2MMqxWVqpnqHlk/3JGcKIWHt1Lo=; b=r/cCtzz6pPNMMOVmtiD0YIpR5OoRJye2IGnSO3vdSVyI0awOlKKl2uby4+vdXq/qZZ +FU9zoi0+0q7u/mZDeN6bjcejErkPKfxgFU7bW1YArJnT6IPJdcl46xUismFAiKMZ20h FWm/iXnEF/CuACrO71cZt/cRQ7GbqgN9DrqVVJdlHpp7rFhJrwOFZ8a71D8pbTPSM3Zl jnCqKtbcYYUAbnLfVCqy5ebmHbrUj2MadIFz+zW8fLm9/BnKZ9vYC/Z6e2TupAOxviDF gPU7F37bBtAxXRu567d1BFimDKSldJMzKZD/Pf+UiXrAowBso10fCooX6kgmRRuR3JE5 m+eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BFespdZf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 29si534809pgk.306.2019.07.18.21.38.58; Thu, 18 Jul 2019 21:39:14 -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=BFespdZf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730663AbfGSEgv (ORCPT + 99 others); Fri, 19 Jul 2019 00:36:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:60340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727228AbfGSEA2 (ORCPT ); Fri, 19 Jul 2019 00:00:28 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C5462189F; Fri, 19 Jul 2019 04:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508827; bh=Bgd0Bw6dCsfqG18nCU1TXezh7rwvgVoQ1pq5kShUpig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFespdZfk4ajjYEZG76H9K9t1aX/GiI+XInOIZUBWXmHRrWSHqbQOv4bnAJEfy4Gz OhwjtWXkLm7Xz3i9qV9xMXWTX8RysO8+Xh64IBjTLwWltFCbKeEhEVc4t0dhPs7HK9 Gn94Ol6VglOkf2cDrCMyOVEefYx1GTw2/GSQhZ2U= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Aneesh Kumar K.V" , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.2 112/171] powerpc/mm: Handle page table allocation failures Date: Thu, 18 Jul 2019 23:55:43 -0400 Message-Id: <20190719035643.14300-112-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Aneesh Kumar K.V" [ 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 b5d92dc32844..1de0f43a68e5 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -130,6 +130,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) { @@ -138,6 +140,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; @@ -154,12 +158,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