Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2701773pxj; Mon, 31 May 2021 08:36:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqp2n5pgZowgjUtAhXTUOqLUfJn5ssiorkA+K/HJf8dNRRZy8uS+pE0n6PZ01GXP1zBmQm X-Received: by 2002:aa7:da8e:: with SMTP id q14mr26532952eds.13.1622475362127; Mon, 31 May 2021 08:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475362; cv=none; d=google.com; s=arc-20160816; b=cNuWC5/DT1B8zTqfWiVyX6SeOo0YAZg15BIhTjbYCFBTXWeayzVo2/D3u7xjYvOGmi TL1ohOoXW5jlhsWE2FKPf1j3Z0VLwF5SdxJKayf4mGALafD2vFEowsFGG1yN6O/ZNhZK G/Qi+1Qxu8rjo8vEh5PgyJoDy5EJ29novyzzrGjC5S9b07Lgdk/wBUpXtxsW5NKuXcwM ETuMhN7/WWBmpDmQSY9H0l3ccDuImvPKpZsVWMe5KuwHQIV5l25X2XkfBCeorB1b3QHH gdGUjXb3Q3dsibxCTkbw6HbWk3kbv93B4NptE4PXh52IAW/8EYQ8IdBp53sCrWsMATPG 3m5A== 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=+NXKEsOYk3j4ZFF/jQ75jnU3QdWVhOAYpOj4MRYTMV8=; b=VJfcKhaL67yDW0TXD+KzUSNt5plsB+mXGxWmiP4msDAsiY9S2YFW1H61+U4Tvgtdua 3BnegrV74PhL9aVLhE29OZx89D9lboOnKVWNoaTa/HpUaVZcBd+YLQgttuhX/bV9DOY+ KPWvujlWxSRsfiRPg5+J/wB7PlL9Q+54nIQWfxJoDmOxSF6yemvoIT2FTfO/DBcCcUIx 5dQ8JuehkfJpsARIO5NHBYouNzBdc1kgyaVKX8qJb3/uXIwpNLOYk2wWGBHSpRjFotf9 SxnrYCTZ7OZU9mIJd0nZCePN1686l6+ybSTQ7gEh006nRNGPkEDA4A7zut55QSDP7Ei+ /Gzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=g36brbs3; 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 w2si15307838edi.531.2021.05.31.08.35.39; Mon, 31 May 2021 08:36:02 -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=g36brbs3; 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 S234412AbhEaPgS (ORCPT + 99 others); Mon, 31 May 2021 11:36:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:48846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233852AbhEaOVb (ORCPT ); Mon, 31 May 2021 10:21:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B4B9D619D2; Mon, 31 May 2021 13:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468709; bh=7DCn1g24tfuBhifxLIxCDG9xA8Au61kv3QYF9m3PP5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g36brbs3A2HzeNmSbum0j/vloGXGVyzuz8gLXtyjdWY36oTEHGEpntYYegigQDTxh tDPbvOx+S3IA2ScnSxysrFRX0VLWfpAtt3TItEfGwsnneubozLr7HGlwD0MVjyJxPm pHyGr1eHWaQepfti3A2xFWH4s6ROab8ab9q5wee8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Seewald , Sasha Levin Subject: [PATCH 5.4 097/177] char: hpet: add checks after calling ioremap Date: Mon, 31 May 2021 15:14:14 +0200 Message-Id: <20210531130651.244857013@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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 3e31740444f1..d390ab5e51d3 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -969,6 +969,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); @@ -982,6 +984,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