Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4131504ybi; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcJ+y1D4jkg8CRFiHVCjcYGhPYN42PLpm1c6lrvF9hTN3HE6Mnui8z6GPJA/IvEGz8hOsk X-Received: by 2002:a65:5b8e:: with SMTP id i14mr105655810pgr.188.1564455455403; Mon, 29 Jul 2019 19:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564455455; cv=none; d=google.com; s=arc-20160816; b=ushcv20/bkmMcTw/6vXxU3HNNuMLrMRjz6q1wg3k1dV+DHcLnFMjBZq45psTutgOSc eAHUGi9aeyeSQXq1Uu3D6uncQakM40xAUdPONu2mGl7N0+oIYidK5Vc9ArEioNLP7cgq iW6oqd5HEPgxaMH4N+lP76YzR7c96+2Z4WcoDEzmazqbhgLbHHqihonedPfEA62ZKiBV ULUfmI2tGYxE10BD+HymS6eir02fYT1Rhzg+kaW/F11V6gobaTMrJ2FrEzfnEjNP7NxT 69bLWSQ5gZggI0Mf774ssosEbl8k9sbg5iCSQ6sIbArkmxRUxY5CZ/LA7JEUQnuPhB1k 6Gqg== 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=j5cI9CqSsjmwxG5IzCIkKB07zygoBHFISLuHLTucSgc=; b=D0Yc54vJUZk9Rp4mddAui0XaKmUP+aiUNjI5EmS/C3QvzEoCRMVo78vE3nIgRLdzhN Yv2dO+PeMpKWxCJ7xBVSdDxsWnAOwApHRFs2Wg0CZ8syvYZCtWpZYgRRU/GpDfbACSkW ad/wVm0cByAwMD/GytxvdGOqiB1KPAcOukDoXTrTjdw9yJcLdN4X25t4L9GXBlNYDaaO PpUqOK56lgtOOakqTcM2sv65hrjd3M7S/PCftE+wsJqWwl5BVvSrDXLKecqukyZtWl/D vp5uTumaNSdPdOyUKJNBwI4KUmkbx1jSCjK3qiKc2v76AQn6iO6Rkp6X4RGr+Y7nvA6+ eJtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2KA/X/oi"; 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 a33si29089089pgl.436.2019.07.29.19.57.00; Mon, 29 Jul 2019 19:57:35 -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="2KA/X/oi"; 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 S2390686AbfG2Tuk (ORCPT + 99 others); Mon, 29 Jul 2019 15:50:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:41638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403814AbfG2Tui (ORCPT ); Mon, 29 Jul 2019 15:50:38 -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 519162054F; Mon, 29 Jul 2019 19:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429837; bh=rDEF+DITErTfLFnpymtl2HXEVbtPejU9fdQayjfGECQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2KA/X/oicXZK27xB3BBqF+u7qm0NKX0y3cP3LERnXuwihQhsXvjYy9Wi/jHUZvlFq ZaZ1vo+fi/xftH+VzKPpNtyETZ3nwxXil1wxBT952DvwSXvBExSk7ZV/2s2+y3//3G kJ5Tuz7JkmLUyFfiwmhiTvQukzMIwZ2Qaijo/MNg= 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 5.2 110/215] powerpc/mm: Handle page table allocation failures Date: Mon, 29 Jul 2019 21:21:46 +0200 Message-Id: <20190729190757.976051729@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 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