From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEB1DC10F0E for ; Thu, 18 Apr 2019 18:04:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1270218AF for ; Thu, 18 Apr 2019 18:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610660; bh=7EUKk0gCF+XfOroSFhPic9E505DvNxWvN0uAUSEC994=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=KgGyOf7EKWPuudlXRfCfEaRe8XXfk0PLlycOnV30rlIB/pw4m2sz6VHOencXt6vbS 1KwyzC2gh68UCq1E2gAZyfVXdaWlxVUm2UKrhF+V7cPqsZY9Byddkc+SWEAhRVngsF zSMofJZG0LDwPa31re6jpId9Aqi9EE/xBCQnO2Y8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391083AbfDRSET (ORCPT ); Thu, 18 Apr 2019 14:04:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:33110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391074AbfDRSEM (ORCPT ); Thu, 18 Apr 2019 14:04:12 -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 568CC21872; Thu, 18 Apr 2019 18:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610651; bh=7EUKk0gCF+XfOroSFhPic9E505DvNxWvN0uAUSEC994=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s69Wz/m4LlOFtUgDme+0Viq3hISMPb7wHjEIMtWfgTSbU0DCCrE46PrrzAKRaL3KA LYxvEQ30pkxCBaVWTaUvvi4c00b3rGUF1YS33YW6R8t5gOOIcMbl10U69sLyWuoWZZ 1DZmL4N52/j7xnykf9rcGCJArMG0HFUZ/HfpTUX0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aditya Pakki , Thomas Gleixner , kjlu@umn.edu, Borislav Petkov , "H. Peter Anvin" , Kees Cook , Joe Perches , Nicolai Stange , Roland Dreier , Sasha Levin Subject: [PATCH 4.14 31/92] x86/hpet: Prevent potential NULL pointer dereference Date: Thu, 18 Apr 2019 19:56:49 +0200 Message-Id: <20190418160433.162086306@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160430.325165109@linuxfoundation.org> References: <20190418160430.325165109@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 2e84f116afca3719c9d0a1a78b47b48f75fd5724 ] hpet_virt_address may be NULL when ioremap_nocache fail, but the code lacks a check. Add a check to prevent NULL pointer dereference. Signed-off-by: Aditya Pakki Signed-off-by: Thomas Gleixner Cc: kjlu@umn.edu Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Kees Cook Cc: Joe Perches Cc: Nicolai Stange Cc: Roland Dreier Link: https://lkml.kernel.org/r/20190319021958.17275-1-pakki001@umn.edu Signed-off-by: Sasha Levin --- arch/x86/kernel/hpet.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index afa1a204bc6d..df767e6de8dd 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -909,6 +909,8 @@ int __init hpet_enable(void) return 0; hpet_set_mapping(); + if (!hpet_virt_address) + return 0; /* * Read the period and check for a sane value: -- 2.19.1