From patchwork Thu Mar 14 07:33:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10852275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6D071515 for ; Thu, 14 Mar 2019 07:33:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A75012A20E for ; Thu, 14 Mar 2019 07:33:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A4132A212; Thu, 14 Mar 2019 07:33:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B8AB2A20E for ; Thu, 14 Mar 2019 07:33:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbfCNHd1 (ORCPT ); Thu, 14 Mar 2019 03:33:27 -0400 Received: from mta-p5.oit.umn.edu ([134.84.196.205]:58680 "EHLO mta-p5.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbfCNHd1 (ORCPT ); Thu, 14 Mar 2019 03:33:27 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id 1A3FCCDC for ; Thu, 14 Mar 2019 07:33:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rYjCJwciMXd1 for ; Thu, 14 Mar 2019 02:33:25 -0500 (CDT) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id DDA9D6E7 for ; Thu, 14 Mar 2019 02:33:25 -0500 (CDT) Received: by mail-io1-f70.google.com with SMTP id k2so3661597ioj.2 for ; Thu, 14 Mar 2019 00:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=2KdFAd7hIIoInlHZ9K0V/3XCy5cD+1K+fdIT5yyXtd8=; b=kULQ0WtzP73Vvqdf9QfDwv9Y+au4RDVoy9vcVFKYCbVju58YxY8XNzrHEee1sjYFqt atl2MVPEtK/MUetfOcE7LOOScNsZzVwVpJyTvzPLaC1BmjV6zEiJs/ZU4wROvsnWiWOl gL5NIsSP11xu+6j6eJy6RlnPm2ulANUD9wQpIdL435NmA8bqiOzqUwtkzkRmF8Hi2/YD xQN22QY5CZ+27czwr+FC1WqgFgCsv8W1dcIxORdLg9ebhVvRSOiuB5utWs3LEVka4wF9 nADZKgxE8UsMwjhQz928OACPkMfiM5no1H9GAOZu0lEQ3sPYfDjqsQH0zxA+heD4fu5l RYBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2KdFAd7hIIoInlHZ9K0V/3XCy5cD+1K+fdIT5yyXtd8=; b=rYlIwi0NygY8XCtEUsQ/RAI1l99bXtTHRZUxhF0cvfr6iHNbGnJRR+t02Kvs3JTfD/ dcH6J3ZtbW11xNFYSXz/vcT2ZeeWij6m70OIc/M6gKdykEGN+MAsEIBmay0lZngCJECf MP8+Vr5OhliArw6KgbScqheSHG2W+Qxc1fNqlI6cDdMBJvyWAUOrm7jD6l8eLO9cIZ7T pwg/ytQEEbrth4ANB8XwB8Vh/FaYnhQJyxGVsQ4ypHrjGZ0sTs9RUs6w3xgki02TGnXZ M2I9e6jCd/epLvxq3MJcXqwrv5QmFfZgr15rXFNHY5e2NoPjYs7FSv01ihY3ux2g6RJz TQdA== X-Gm-Message-State: APjAAAVMr4hszIjoHkraZ2VZNdV4QIRy2YR2894QefzEArfmGpfi6Dus f3726a0lAD0nWs3H2EE4+4WGuKEfMcTrQYJS1snNDKzYdkA3WP4pR7AV28Poyy7rzQOR5CZtEOt aQ9fGwpSOzXFql6ADZIYRwt3ArkM= X-Received: by 2002:a05:660c:fcd:: with SMTP id m13mr1358833itn.77.1552548805526; Thu, 14 Mar 2019 00:33:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqypa2fyX0AVw20mZGED1IerN1dmBKtxViLlhgnyyUBZASgB39ubfjPHAiN9ExxhX1NgCpDHKQ== X-Received: by 2002:a05:660c:fcd:: with SMTP id m13mr1358823itn.77.1552548805320; Thu, 14 Mar 2019 00:33:25 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id n6sm907151itc.0.2019.03.14.00.33.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 00:33:24 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Bartlomiej Zolnierkiewicz , Finn Thain , Rob Herring , Greg Kroah-Hartman , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] video: fbdev: fix potential NULL pointer dereferences Date: Thu, 14 Mar 2019 02:33:17 -0500 Message-Id: <20190314073319.23209-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case ioremap fails, the fix releases resources and returns -ENOMEM to avoid NULL pointer dereferences. Signed-off-by: Kangjie Lu --- 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 5d9670daf60e..2e321d73b3a5 100644 --- a/drivers/video/fbdev/imsttfb.c +++ b/drivers/video/fbdev/imsttfb.c @@ -1515,6 +1515,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;