Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2637841pxj; Mon, 31 May 2021 07:07:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5s7mJNza6k3gMyMAWH+jjWMkJPK6F4IK/hkxXTQD38jJ2iy4fUbqSJVBEkohek5BmIqEJ X-Received: by 2002:a02:91c1:: with SMTP id s1mr20737541jag.61.1622470064242; Mon, 31 May 2021 07:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622470064; cv=none; d=google.com; s=arc-20160816; b=CVCXtG3W5/6MZzPuQEJD4w50zOWvh/O9btIOqn6VZFVIslWWYw5TH4r5pJUXWKst4i NX4RRHYL6Y8k2GQglWW+ArKzowMQIJkPhSEaASM5X1crztWzFBuULokmRqJf32GYCdxa rj5M7nIckVel4e7gR+XGNjDXB8rrv6pJWhdYEOBC3yHVBiWX9D3tBxMkYuJnEf97ADk4 Yxoown4cYt9O7mV5rxDW1pLXGqrzvfm4xtbx/heWDZpumeYCpGK28xRfffE+BFXPXOAv N+URPqy3vU3dZGIE42F39MeZMw+BwRYB8FZ6bCgo+74iGvuoFugn9zsN70suh5bk4n7P iXEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cp5GwqBmN5tUiQLZUbGPmOwmEqg2weaVqMOoo/RcupE=; b=ywu1DbcE2jkx9BLJr5RnCDHmhVZp4HPCcqussKw37b+GbyUUtctG8YPzhSato8WyLU KbPdTjiiQ4tS7WbqTIYLnIg++3EPTxkG95kU7oAZcWYebzcUEmmAVdOIS5zExh08qjav L/8K4v3slpcW0sp7HFiO/mQizEhCufw8UUz7iNS6mkOyYXEs95GV5jco+e2mXXs2MIKG 2uSQzYz6CrWTLeh0t9/8oxZs088xu8nIX9Q+CTLc9bNtn3nHQ0VyWScd5H79KHXnbr0q cC6JtyC7RFAOVLWPGuxDA0qKpvspnEXR5DrsJpBkFkgZnU99buRRb0fjeO5nWNdT+lxy sgiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FdJDsdtS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h21si14018986jav.99.2021.05.31.07.07.31; Mon, 31 May 2021 07:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FdJDsdtS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbhEaOHD (ORCPT + 99 others); Mon, 31 May 2021 10:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:44890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232858AbhEaNmf (ORCPT ); Mon, 31 May 2021 09:42:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 902006147D; Mon, 31 May 2021 13:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467703; bh=iFoHbmoRfsF8UqahWydgX8ijJLz5v2TsAOTGswzRmLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FdJDsdtSMa2BqQXpvONuQjleF9Hlk++6NDWeEfsRAfRIQkWktlkD6M4Bgu6oiPzXf zVhrpFKD+Xp+AfHZJNAWMU+WKutVcQBhvZE6yLedXbpOEbEIJmUQKZahYn7/tQ+Z9B +oEDiDt78I+DVZXskCQCn3Pe8YUHrfFXTajz12Hc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Seewald , Sasha Levin Subject: [PATCH 4.14 49/79] char: hpet: add checks after calling ioremap Date: Mon, 31 May 2021 15:14:34 +0200 Message-Id: <20210531130637.580292263@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Seewald [ Upstream commit b11701c933112d49b808dee01cb7ff854ba6a77a ] The function hpet_resources() calls ioremap() two times, but in both cases it does not check if ioremap() returned a null pointer. Fix this by adding null pointer checks and returning an appropriate error. Signed-off-by: Tom Seewald Link: https://lore.kernel.org/r/20210503115736.2104747-30-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/char/hpet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 05ca269ddd05..b9935675085c 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -977,6 +977,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) if (ACPI_SUCCESS(status)) { hdp->hd_phys_address = addr.address.minimum; hdp->hd_address = ioremap(addr.address.minimum, addr.address.address_length); + if (!hdp->hd_address) + return AE_ERROR; if (hpet_is_known(hdp)) { iounmap(hdp->hd_address); @@ -990,6 +992,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data) hdp->hd_phys_address = fixmem32->address; hdp->hd_address = ioremap(fixmem32->address, HPET_RANGE_SIZE); + if (!hdp->hd_address) + return AE_ERROR; if (hpet_is_known(hdp)) { iounmap(hdp->hd_address); -- 2.30.2