Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2622613pxj; Mon, 31 May 2021 06:47:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwy+xVHvDBYyXTAEpaThdw2QmG7tSpNhsK079vsOPRhjW8jXHpE+ZigoQaK6jZqcCeBD3wx X-Received: by 2002:a6b:8dd5:: with SMTP id p204mr17345589iod.195.1622468864554; Mon, 31 May 2021 06:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468864; cv=none; d=google.com; s=arc-20160816; b=XCOzsrdee277B3oXMoWMjgXuNijaV8DvP88a91pyYHhpkoUNaD7G/gc0/eP4YwHDxP fSyoxE/Fc2w3PEEaMlnka0G5YHK3dNihAFeCQo5UDgpYsD20okkE8858CDzutpp9mf81 T3mNE2xIQDznel2WUjcopAWCL6pJ0scK+8bo667K7wa0VbVD9W2Zum2Gi0DqiSkZZV/M nx8eL7fYzZyVb2GAu6tsSmpwAz3ehmCU0PBhNKmsOuHg4kWfV5YcERZc4ta2/dVszKg5 sG14nJQ3yoHMh50VIyJvg+7qNMtHKeAqYrSfv+AC9fCluddxqxM/7XF/lE3HaAOl1A+n gifw== 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=yAiHQTYTt2ma7rCqkju5ocQcL6slkbNZq0C8k/PXzOs=; b=RD5174K/YxwfH7YsFResXnEELOJUzsu41yKdaW4DOGKE54jC7aR6ZJ+Pbq6c25gJ+H yshSwp365jGky7Kir7G/ILNo8Zwwihs/qswZDSm+lKIAZTHWEjBWV9J5F06U4zJM2Zac p4lThjm4Dry0IC0EfLgyau9u40A+GJ/oqTCoUci7nokWEpCXspiGnd7RxWFwPOHsSylq YV2xx3qnz/DBzb3/Jr5dDcIVWoEsEIsq+XnZ1Y9yd4ybrL2GPzZY9z1ZZEBQF2y8S12C ghbSXthm/N/IxteGRcn8BZl5fbaZOQa0CC8pYJghMdZ0pMMFUV3RfUbEnfsR0wNNgaO/ brlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xr7ho8ZR; 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 y17si14221698jak.57.2021.05.31.06.47.31; Mon, 31 May 2021 06:47: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=xr7ho8ZR; 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 S232114AbhEaNsN (ORCPT + 99 others); Mon, 31 May 2021 09:48:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbhEaNd0 (ORCPT ); Mon, 31 May 2021 09:33:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E27C2613F8; Mon, 31 May 2021 13:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467472; bh=y6ROu5eN9pQ2wCzIAShtXihvPD7tlVMrdeD5Oy/jc38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xr7ho8ZRrzFfQXNGqlT9H0zLOFWgH3XfG8H7ye3GikPprvW54Pnb3ssNGXwr3QYRA VmPb7gUHiUXTyX+yGMY9pNHH7ZtgbGJCXV++Rn3klQUJhEUhZX45Et4U0F/uZdEG+Z rFwLON97fyzYhXTkAbHF5lkcxZ/OGvi55qvFqMjk= 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.19 079/116] char: hpet: add checks after calling ioremap Date: Mon, 31 May 2021 15:14:15 +0200 Message-Id: <20210531130642.837690037@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 c0732f032248..68f02318cee3 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -975,6 +975,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); @@ -988,6 +990,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