Skip to content

Commit 1d6d3cf

Browse files
tom-seewaldgregkh
authored andcommitted
char: hpet: add checks after calling ioremap
[ Upstream commit b11701c ] 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 <tseewald@gmail.com> Link: https://lore.kernel.org/r/20210503115736.2104747-30-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 740b532 commit 1d6d3cf

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎drivers/char/hpet.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
969969
if (ACPI_SUCCESS(status)) {
970970
hdp->hd_phys_address = addr.address.minimum;
971971
hdp->hd_address = ioremap(addr.address.minimum, addr.address.address_length);
972+
if (!hdp->hd_address)
973+
return AE_ERROR;
972974

973975
if (hpet_is_known(hdp)) {
974976
iounmap(hdp->hd_address);
@@ -982,6 +984,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
982984
hdp->hd_phys_address = fixmem32->address;
983985
hdp->hd_address = ioremap(fixmem32->address,
984986
HPET_RANGE_SIZE);
987+
if (!hdp->hd_address)
988+
return AE_ERROR;
985989

986990
if (hpet_is_known(hdp)) {
987991
iounmap(hdp->hd_address);

0 commit comments

Comments
 (0)