From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F0FBC28EBD for ; Sun, 9 Jun 2019 17:03:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BA9E20833 for ; Sun, 9 Jun 2019 17:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099806; bh=v5+OdRiroJNePL+EMSWqYBpZD6+2xfylolszboFxqXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y1Vbjy8mHTMQpAuvryC3MrDDoGCvFs9nuJiJBO4L6oPMdAKYbTvk0PbyBX+BkIX+t TLMk/Vkjvz3UBjQhLadJs9cLGrTXPR4Vx6wjsFgBy1nOTXY+8RyerpDQBHeD8C4CNP XhxhxFI7hBXv+U8aj1N5Fxtk7JEWHxglpXTIi6+c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388412AbfFIRDZ (ORCPT ); Sun, 9 Jun 2019 13:03:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:41628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388367AbfFIRDR (ORCPT ); Sun, 9 Jun 2019 13:03:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A3FC20840; Sun, 9 Jun 2019 17:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560099797; bh=v5+OdRiroJNePL+EMSWqYBpZD6+2xfylolszboFxqXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bB5q47QC3PnO/54wxQQdkZQyDJchgT6J7Q1fJvo3gB8LnrcGyDsO08nyaUVR7F+2H Hsy1/Fo9050iENQ1Hk/P4+sZ6D/PAQB7ra3HhB7XwP/xmL53C8pePXNv+y4ravdRi/ uAe/eLjCC0vWDHuXYA4bLfrdqg4xTXAJjGEWMGwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , David Sterba , Sasha Levin Subject: [PATCH 4.4 168/241] tty: ipwireless: fix missing checks for ioremap Date: Sun, 9 Jun 2019 18:41:50 +0200 Message-Id: <20190609164152.626825312@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190609164147.729157653@linuxfoundation.org> References: <20190609164147.729157653@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1bbb1c318cd8a3a39e8c3e2e83d5e90542d6c3e3 ] ipw->attr_memory and ipw->common_memory are assigned with the return value of ioremap. ioremap may fail, but no checks are enforced. The fix inserts the checks to avoid potential NULL pointer dereferences. Signed-off-by: Kangjie Lu Reviewed-by: David Sterba Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/ipwireless/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c index 655c7948261c7..2fa4f91234693 100644 --- a/drivers/tty/ipwireless/main.c +++ b/drivers/tty/ipwireless/main.c @@ -113,6 +113,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->common_memory = ioremap(p_dev->resource[2]->start, resource_size(p_dev->resource[2])); + if (!ipw->common_memory) { + ret = -ENOMEM; + goto exit1; + } if (!request_mem_region(p_dev->resource[2]->start, resource_size(p_dev->resource[2]), IPWIRELESS_PCCARD_NAME)) { @@ -133,6 +137,10 @@ static int ipwireless_probe(struct pcmcia_device *p_dev, void *priv_data) ipw->attr_memory = ioremap(p_dev->resource[3]->start, resource_size(p_dev->resource[3])); + if (!ipw->attr_memory) { + ret = -ENOMEM; + goto exit3; + } if (!request_mem_region(p_dev->resource[3]->start, resource_size(p_dev->resource[3]), IPWIRELESS_PCCARD_NAME)) { -- 2.20.1