Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2718996pxy; Mon, 3 May 2021 06:36:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg76Ah2vA0JHuVguB0ik6Fjz574INXA6Ux7HJCd7vIBx36hw6WGNebCJyXjRLGjvpb22wO X-Received: by 2002:a17:907:2075:: with SMTP id qp21mr17099109ejb.421.1620048971823; Mon, 03 May 2021 06:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620048971; cv=none; d=google.com; s=arc-20160816; b=fN76q7egFIXwRaTyGUKStjKPQPjsQ14myCB+7cGvHA3jidhUH6WCR0C4HJJkQyuhwc TA25Yg4TbYquZiJLjkP+4JluxsCTuByJkNkzLgK67obV8n12snQjYDtEqTg8PaCpJyRS H9saaaAPaIOOBeZdDD/acDYwY3PxD1MkPIxun4l/Ed61k1A8lEa8xjFm7fGw4C/mnb+7 oJH7G2BJ+NwEWS9KwMMzqINKiugjZ5y1UV5pKveRqZfe9lO7FuOrnQn3mTumN61vGgKI d7oGWMbyXHlLg8Skfa6JgA7zDzUWRxdByBVEGH7O8ZK1/k0JX9gL9548r2hd1i44B4qi 70hg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RSpv57N9RMNynYE7RWwO4XrKdHLe7QI7URu9jPbEKB8=; b=Boqrv6hkmX/Vew+ZxAoalDnfbbq2QUvIbHjlEUBY6/r0t13CjUY6szNtdz0/VpjHNL lcdvdQCaa+K7Q/jcMlE4KGddMKsamJ5XPNwi7owQaWHarEcJdzUTKbOig4enFjsiDD/E hCi2Y/JFJYkEJmRTtR3exROOoPqg71k0eWVQYIKLnWy32Ur/18e2aHu4Cm1W2Zi7lCPO wpieDfdnIbTbtQitpgWCxkXZKJUse0nkpIG20PCvVLV/6moBgrNeTA3fZ0ZmsAoCv8Hc MgNpC4zOjUQ617qW+kLUo5hkXvoMlFqpgD6jQLsDt7GEXASspcw+FD0QkxjVWDL/4Z9q mrxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KAuYq6ZG; 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 s25si471336edy.17.2021.05.03.06.35.47; Mon, 03 May 2021 06:36:11 -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=KAuYq6ZG; 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 S233792AbhECMDr (ORCPT + 99 others); Mon, 3 May 2021 08:03:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:37122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233942AbhECMCJ (ORCPT ); Mon, 3 May 2021 08:02:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C25361369; Mon, 3 May 2021 12:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043275; bh=bFZH5Wvhc2cF0gXWbmzW/UeKcRjcXWb02hgTLQwsN/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KAuYq6ZGqyJMqefCmqzW0w1W/ib520kIbqzn1j4tXF0VSaCJeB05hg7NeDHn6k+BZ pABbqwriYO2rz5AKhhjeOccSTkrr6EoYGhnhUPidew96K1zUPbLvJKCXXJAhfD6H7j 6Q4X/yPbJyYI2WKJgfmHTxkKPX9Vp/CAIFr0DroE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Finn Thain , Rob Herring , Bartlomiej Zolnierkiewicz Subject: [PATCH 67/69] video: imsttfb: check for ioremap() failures Date: Mon, 3 May 2021 13:57:34 +0200 Message-Id: <20210503115736.2104747-68-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should check if ioremap() were to somehow fail in imsttfb_probe() and handle the unwinding of the resources allocated here properly. Ideally if anyone cares about this driver (it's for a PowerMac era PCI display card), they wouldn't even be using fbdev anymore. Or the devm_* apis could be used, but that's just extra work for diminishing returns... Cc: Finn Thain Cc: Rob Herring Cc: Bartlomiej Zolnierkiewicz Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/imsttfb.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/imsttfb.c b/drivers/video/fbdev/imsttfb.c index e04411701ec8..16f272a50811 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1469,6 +1469,7 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct imstt_par *par; struct fb_info *info; struct device_node *dp; + int ret = -ENOMEM; dp = pci_device_to_OF_node(pdev); if(dp) @@ -1504,23 +1505,37 @@ static int imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) default: printk(KERN_INFO "imsttfb: Device 0x%x unknown, " "contact maintainer.\n", pdev->device); - release_mem_region(addr, size); - framebuffer_release(info); - return -ENODEV; + ret = -ENODEV; + goto error; } info->fix.smem_start = addr; info->screen_base = (__u8 *)ioremap(addr, par->ramdac == IBM ? 0x400000 : 0x800000); + if (!info->screen_base) + goto error; info->fix.mmio_start = addr + 0x800000; par->dc_regs = ioremap(addr + 0x800000, 0x1000); + if (!par->dc_regs) + goto error; par->cmap_regs_phys = addr + 0x840000; par->cmap_regs = (__u8 *)ioremap(addr + 0x840000, 0x1000); + if (!par->cmap_regs) + goto error; info->pseudo_palette = par->palette; init_imstt(info); pci_set_drvdata(pdev, info); return 0; + +error: + if (par->dc_regs) + iounmap(par->dc_regs); + if (info->screen_base) + iounmap(info->screen_base); + release_mem_region(addr, size); + framebuffer_release(info); + return ret; } static void imsttfb_remove(struct pci_dev *pdev) -- 2.31.1