Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1906528ybi; Sat, 1 Jun 2019 06:29:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4cRjOZTq0DB299kXYGe/vX6qbJUQD+vDYMJgtjiwKSU/xVmJ4uStwyBQMXeAvr0UY3WnI X-Received: by 2002:a17:902:a986:: with SMTP id bh6mr14362072plb.100.1559395764142; Sat, 01 Jun 2019 06:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559395764; cv=none; d=google.com; s=arc-20160816; b=PVRQevsryE3ZH7Gm2JdIVwjt0F35d4aHcJ+GqZQL3m8qkuqlYBSavggyy0Emfff4L/ rG9QRKZJvZv6OvD172URmrOTzhKHCZ4roz63rn6+CU6y3tR3ZbmQFKNPDtUPXJ0HL8bQ cScu7mi5RYOzksfbznytJFoQ7yIHxgeVpO/8hIgvlRckP3JYQh8FqRXZBnwwEZLypMft /pRGcHCd6KZDPQZdva6ErOqaWzLPiyxdEGoebuwxUyTyxFPDMSb8fCVZbHMukoTZPnPC HymTF83oyTm2j8+cpeoYZZ50WbEcCog7RmeMbCFm0ktsZu9/1n5GQwZ6ODUiOz9zNZeM Xejw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hY75iSu6zz9R3HN/4NfoD03dH5lHjqmAS5zu6o4CJkU=; b=hKrdRqh6rGxbt/bmLsbgfuybQFV4MIgZRyeiaFxneBrOeW1XBd1Flwjy7WGgmNSzQU Gw7lmVUM8hcgg0GgDsOU/mRLm/lqooMpfyYdARq7YJr+wHfTcCRuzxUyyjXSDC8Vc3K0 8Rz9rrDZQ2p1xPcoUz7YcQ2xyolhXHiQukZACv/Xf6i+weZZYzrL565Mh3y6QkPBy1PM 5IPw/4d0HKaIyphLzX/FUslu1Kq3ziG/H50uetk+yeYdcTRcy8j16iAjXP6YKlo4p1en PxfZmNYfThBC9LH+/zutiFzAX5y6V8kBt8H5HivvxHlP5fzfzTuo3LA9Sv4Rm59QYTWX xdgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sA1BINLW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m6si10388058pjl.60.2019.06.01.06.29.08; Sat, 01 Jun 2019 06:29:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sA1BINLW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729494AbfFAN12 (ORCPT + 99 others); Sat, 1 Jun 2019 09:27:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:57990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729930AbfFAN1R (ORCPT ); Sat, 1 Jun 2019 09:27:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3F328273D5; Sat, 1 Jun 2019 13:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559395637; bh=uMYJg1J7W9gwIf64iWYDIHriKB8nkrDVCNLE422qyQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sA1BINLWC5nCjw09TbLN16v6fde2008w3xfj7tv3hdYsYKu1Q5lIusd2kSEEG2StC 1Pjw5/boq9cQJJw0x6j3fV9jbMttPn4SVpguYexb7ElcPJSCeMo6zhXH23u1NBAwEt SGaXysSvCXoaEvy6n2F7Jf4ZQI7an0TmqtUw7Iig= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kangjie Lu , Aditya Pakki , Finn Thain , Rob Herring , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , Sasha Levin , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.4 44/56] video: imsttfb: fix potential NULL pointer dereferences Date: Sat, 1 Jun 2019 09:25:48 -0400 Message-Id: <20190601132600.27427-44-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190601132600.27427-1-sashal@kernel.org> References: <20190601132600.27427-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kangjie Lu [ Upstream commit 1d84353d205a953e2381044953b7fa31c8c9702d ] In case ioremap fails, the fix releases resources and returns -ENOMEM to avoid NULL pointer dereferences. Signed-off-by: Kangjie Lu Cc: Aditya Pakki Cc: Finn Thain Cc: Rob Herring Cc: Greg Kroah-Hartman [b.zolnierkie: minor patch summary fixup] Signed-off-by: Bartlomiej Zolnierkiewicz Signed-off-by: Sasha Levin --- drivers/video/fbdev/imsttfb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index 9b167f7ef6c69..4994a540f6809 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1517,6 +1517,11 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) info->fix.smem_start = addr; info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? 0x400000 : 0x800000); + if (!info->screen_base) { + release_mem_region(addr, size); + framebuffer_release(info); + return -ENOMEM; + } info->fix.mmio_start = addr + 0x800000; par->dc_regs = ioremap(addr + 0x800000, 0x1000); par->cmap_regs_phys = addr + 0x840000; -- 2.20.1