Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2744857pxj; Mon, 31 May 2021 09:39:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVEdU7+BWHoDvOfN3u57ryQUcd1csQH20CZ3rA9PsoNxvhvBa8tuQ1Zju/nlbv3bo2alPK X-Received: by 2002:a17:906:a1d9:: with SMTP id bx25mr22982230ejb.363.1622479149821; Mon, 31 May 2021 09:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479149; cv=none; d=google.com; s=arc-20160816; b=sdVz+6lYWGOL4Jp90jqyyQ1SA4hf1OXaEyXImTVqOYnsagIRORro3X0A1k7YTTvw46 gbBKAe/1kQLAW/UpxPDufnhb02Q2sljNS368eBE3VycXssNO/CNtHo2eWpIcLyf7PJTc nvMGR2DefkS5gbDlAAh94RkYHitpAUkDqvFsfULXipR6AHleY1NLM6/BYUcwGvhqbSeV tOPTkg+2R23TLJ3fRVwE7dhwh1hM8kvUVZtUjlMoOP+UuWJDnJywOUyNHhMyjzgpKNmf DV5D5y/HQ8t5hMZgWm1F5iotxxQbYIEetuN9KRycDrC7+FzinSMPcVKVVi0ydVwUFxOg 47jg== 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=rt2QmY1623wXBnjte4xgCFGc2tZHJDOP3Gwdf0GgHuq/ID/VPXE4qHApB6ckT4Va0Q 0chVSMWA4bqYpPs3FTsMGVF8S+Z7Yiyii1EBcHBnkzIORXPylO1ui1prxBDq+MKlbfEh qoScWdcQeiBwymRbL6B9YJ34ridRaxlmMDLbv3RB94z/CktULAOWJzr5Kt15mufuWmF3 yBaS8xqC+t/qINEhxL32Us/eO+fO1ir7JhHE+lSwoyGtFmT5QtLGRwJxUUhZm8F5KBnn djIBXdW3F0PYkEvFraLnGJcTu6sP9FRzi3hHHJIf6sunISJqyP5wFv73ZVeLmS6NOVg/ RFsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="o+e02q/Q"; 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 k17si8304389ejk.238.2021.05.31.09.38.47; Mon, 31 May 2021 09:39:09 -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="o+e02q/Q"; 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 S234787AbhEaQje (ORCPT + 99 others); Mon, 31 May 2021 12:39:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:47912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbhEaOvQ (ORCPT ); Mon, 31 May 2021 10:51:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FC1D6192E; Mon, 31 May 2021 13:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469468; bh=H3RWPZJkjVUorJnG3KIjbbaqmQVKkbapPblliMH5WxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o+e02q/QjPb7K+0rJJro24BkMWetfzfaVVsS3CKSW1DjBOsceUobJIMCDnDuN2MZA s9CSxyYqruM6Zwo6ZWH5Y8m58DYbVjUbPAgOnAgLCDdO3rKhWTlJ829JXA4D57EPmI kv8MY1vF7MF/QS2m+g10ztp2uYVJVLTuAb4LrAu8= 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.12 174/296] char: hpet: add checks after calling ioremap Date: Mon, 31 May 2021 15:13:49 +0200 Message-Id: <20210531130709.730443595@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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