Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp885213yba; Thu, 18 Apr 2019 11:11:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt+GEEmg0LrX7HohppTS1VW7vvtJvoIyzdDFJHlPUigAAqCVBWnHFZL2rdoO6tcKftkas1 X-Received: by 2002:a65:6295:: with SMTP id f21mr84133411pgv.129.1555611083036; Thu, 18 Apr 2019 11:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611083; cv=none; d=google.com; s=arc-20160816; b=AmEtX5Sr7HJw51nZC7eF9DxkpBwi4I1QhhfEDtEoSdoV9OQnvSowh0Nu6HCI4BBvTv daUC2iauRSxQlIF62IpN+/5n8Vy9FvtVDvXxH2m2DeCvAv2MemPOm/eZ8s/V2/t0DRdm qq0MKwKcUKRDY1t2vPOTHuDgQjjgXmqomxDO2HVZUyQWGv8ol0nizEQfhvZ8JmkzVAYx ZGogQ93MoY/0h2RngGPXSY3lEfdLG7B9j7kBlfYwDtlzreu8eWeR8E8w+RJLHiZonBgY J5gL8JDHqBexy6cYKSf/9xWQgybuDIyr3XGy2LZt3wRU/9bRlUAfhU6HIdRRY+aRFlx2 8hnw== 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=rJAcog7/Klx9ew1URnAeVQKuT0sJFp8DuSuI9eEwETc=; b=wG08OlWFxeF11gP1SED3PCuq1TWE4cEQWM76at1Mn4zBJDRaA25zx7cPSr6X3BHjtv +9/ZJdkagA7C2c2tk6sYsOnO9XR+miir9P2Bzmg02i6XqCPHwiX+Vcbf28hmwRwS5CUw vrmRbJoaWM8k4Du4hOXksAImikGVhiEsJFVf35ZTVqlRegsuiFPo7v5RQzdttrW62aP1 4o6SGRdGS4VXOEHpjgF3iaI4bJi5tm6yo3sCM7tXEUtrFGEciB9qzgA/aM9682EmhJiS aZPdiGQJKFJo9RzYQpDFHMNwWuCbBIrYo+jkMUq+tnWgLZ5bWB1IjgOfkUxtC6KYt0lc hdwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ORx0xFSm; 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 o185si2450247pga.164.2019.04.18.11.11.07; Thu, 18 Apr 2019 11:11:23 -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=ORx0xFSm; 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 S2403926AbfDRSJ2 (ORCPT + 99 others); Thu, 18 Apr 2019 14:09:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:41052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403910AbfDRSJ1 (ORCPT ); Thu, 18 Apr 2019 14:09:27 -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 43C2F2186A; Thu, 18 Apr 2019 18:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610966; bh=gZChVrJ+cGg/SxkavZOKHqYOzON8o9lR5F24UDVr41g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORx0xFSm3PzP1SyY4QZBcpqGbdmCgdZ4ddnvirr33Mbg3MV/mdBeik3LJqlKrKMRR S+0NYDyY7UCzOdJbeyPTBQ6g7MUqdoisFHYjIVr7tP2pLiUoWEtBSOMypmIBLwbpJe GHp1Kwpq6VnODsKYjXusvZTJX2hDL2+F1AHzpoQw= 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.9 22/50] x86/hpet: Prevent potential NULL pointer dereference Date: Thu, 18 Apr 2019 19:57:33 +0200 Message-Id: <20190418160425.382369567@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@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 756634f14df6..775c23d4021a 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c @@ -914,6 +914,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