Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2665002pxj; Mon, 31 May 2021 07:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiYhygfCRah6Q9/xLFRku8x3MifQdS93k0IhJR1Hwtew348MW558kxJuA96L4FMnNqn8s/ X-Received: by 2002:a05:6e02:547:: with SMTP id i7mr17703023ils.281.1622472347664; Mon, 31 May 2021 07:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472347; cv=none; d=google.com; s=arc-20160816; b=mX8uUqb9eGAeii+dty5cK6wiB3DVhN69NttmBGA562StOZQqyBclSvLksjkMuSDktx 9nQpsq4woq918SkqNVHmNR8b2mwcU7ajmu8x2+Gq2ihuM9UD49/kmAkDcFyUXiAqsxpf WjGpF9au+jIAAFnF/E0bOiKVtcckHypOSC8nbu9aCJJ72wTKKH9xYJh5M28GVtHR8YEy GlGUGU0+xoRvUB9k7gXOZflKxEAQcSDp28ER+0F+/9IFgylStQ73b/SU4Y1jeq1q5Zj4 NodjKCyxDXKhw6FsQVFseu7FhFebm0d/WjGNRvL2HAgRV6DBO6CmgN9nZsBGvN7/zoDM 7HOg== 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=xWab5/42crY8Zx2bx5n4YV3zHeS851FiSgRQ/6BU6N0=; b=fIcNJ599a3HG/35J7iXrh+cNvojKwFlnTyacWtHWgwOSgQG3cVXsv/4iQ0DVF937U4 NHS0bxHnApsoNYVsHubKaxObsJhBh7fENX+GaI5YrJwBrCWO6Y/hXaJZeZ07Tm8TxrpA ZLHFl1pUqwngOU7nrcykKypej77S5uhlRIKXT5f3P5/Qmvwi7clSXMWa+yFMBXhvInGE mjBg7bV2E1KQSaWIwkiBOEU49oL7oNJq8XPtZhOhD+bLRY5ZgcgfCsqvRvmeW2ijcyQn Eerd4DPiyiNTR+NVzSkTC2adIWpWOb2lvK6DdRhTf41QB/NdBh9/O7gGWIbr+CSd/FVQ yJAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PBUI6ilM; 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 h21si14149213jav.99.2021.05.31.07.45.34; Mon, 31 May 2021 07:45:47 -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=PBUI6ilM; 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 S233281AbhEaOqd (ORCPT + 99 others); Mon, 31 May 2021 10:46:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:60414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbhEaN76 (ORCPT ); Mon, 31 May 2021 09:59:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7CC7961441; Mon, 31 May 2021 13:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468178; bh=H3RWPZJkjVUorJnG3KIjbbaqmQVKkbapPblliMH5WxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBUI6ilMNXZKbNi4ihJrZye8MJ231VUgoTJG8jDCD9DJVrIHWxpTn1oMe4Mt9u7db VLC28OnGz2gU/W2QntVtuwUBhAJRQovaNT4Lj0zKTS8PnknalgwA+yC2LMwEWxv79O iQyz9aAb3ITKHXe4Se5soAIO7wuJ0v9OczRsSm70= 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.10 144/252] char: hpet: add checks after calling ioremap Date: Mon, 31 May 2021 15:13:29 +0200 Message-Id: <20210531130702.910000177@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 6f13def6c172..8b55085650ad 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