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: 10852413 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 1D7286C2 for ; Thu, 14 Mar 2019 08:26:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB592870C for ; Thu, 14 Mar 2019 08:26:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00DEB2A265; Thu, 14 Mar 2019 08:26:09 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6FD3C2870C for ; Thu, 14 Mar 2019 08:26:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6CBA56E21C; Thu, 14 Mar 2019 08:24:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mta-p8.oit.umn.edu (mta-p8.oit.umn.edu [134.84.196.208]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7AE6389F08 for ; Thu, 14 Mar 2019 07:33:26 +0000 (UTC) Received: from localhost (unknown [127.0.0.1]) by mta-p8.oit.umn.edu (Postfix) with ESMTP id 1AE43B73 for ; Thu, 14 Mar 2019 07:33:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p8.oit.umn.edu ([127.0.0.1]) by localhost (mta-p8.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5tVXsuiiUwE1 for ; Thu, 14 Mar 2019 02:33:25 -0500 (CDT) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p8.oit.umn.edu (Postfix) with ESMTPS id D96E1B7A for ; Thu, 14 Mar 2019 02:33:25 -0500 (CDT) Received: by mail-it1-f197.google.com with SMTP id r136so3927240ith.3 for ; Thu, 14 Mar 2019 00:33:25 -0700 (PDT) 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=kzre6mhiLAaYf+IkFVvJLM8h9MaM0O0CCXGowSnHgUBVT4YPQDWCgEmXw7UpBUe55q NynmHbcXDktZxkgkrabC/eUkCad1OUJK0sXMbMMppyaXNt69ZmsHuQGVei/sqlT2KwNr vkfUeIBhIqyJiv4spvH30SLfcdJzeAF0DH6YTQghW2MRyp9qRNrd17zJCD6N7n9ekvEy hRfjYpkverd+KAt0t/3Cy1DbST8FjRh/zqyEt1slNfzPvCMqTcKJSCwV+hDB2V3AL2Dd gG3vnmzOxHZnSz2esN1a/OPTTBp3/kj4n7QCcqXXejkYzxUOv9FQgqWBPI8g7C8gR7DG 9P0w== X-Gm-Message-State: APjAAAVhcHJbLU5rBQpcNZOqYfGxouJMnfp6oT3ALZlv4R7MNo44qPCf 5Rgyin4ep93uc2FQAcwf+KOo+BBrIuIchQNfp4QwFxP16esgLMh0bOc34A8p8deBuU491+YL+si aTl3QU9QtBb814h5ia08OHz0A//1mx1BC X-Received: by 2002:a05:660c:fcd:: with SMTP id m13mr1358835itn.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 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 X-Mailman-Approved-At: Thu, 14 Mar 2019 08:23:35 +0000 X-Mailman-Original-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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, Bartlomiej Zolnierkiewicz , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Finn Thain , dri-devel@lists.freedesktop.org, pakki001@umn.edu MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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;