From patchwork Thu Mar 14 07:30:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10852273 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 4CB1C139A for ; Thu, 14 Mar 2019 07:30:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E98D2A20E for ; Thu, 14 Mar 2019 07:30:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E62A2A1F9; Thu, 14 Mar 2019 07:30:38 +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 B97362A1F9 for ; Thu, 14 Mar 2019 07:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726812AbfCNHag (ORCPT ); Thu, 14 Mar 2019 03:30:36 -0400 Received: from mta-p6.oit.umn.edu ([134.84.196.206]:56648 "EHLO mta-p6.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbfCNHag (ORCPT ); Thu, 14 Mar 2019 03:30:36 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 20D83C5A for ; Thu, 14 Mar 2019 07:30:35 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L7gGgZw1Ta_r for ; Thu, 14 Mar 2019 02:30:35 -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-p6.oit.umn.edu (Postfix) with ESMTPS id EA463C00 for ; Thu, 14 Mar 2019 02:30:34 -0500 (CDT) Received: by mail-io1-f70.google.com with SMTP id a7so778937ioq.3 for ; Thu, 14 Mar 2019 00:30:34 -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=Mzdr9yLs5nJE6hBnuYkAGMUAiDKHyEEnR54GqF1pxrw=; b=i92G3cKphNuNq0tNBCv/7zjoVRSlX97srz6lq6MshYKBx2X4mOKXoPdsXGd0Juwvi/ GiqmKR8cdOXUaYdgzm4a7aHqYY/0TdUhm4vhIdvzTvFJwM7Bm3XIZSxW55JkeY6Vdl+8 plgXywgvOrTb5PQ7DKtXg6yxxZiU9DgWDYPl/UCvTXRDVkm1AJ7dx+mHhLOuUOOsahSG 1fRN1isFn31J9yLKP6zPc56e0+I6gER98bJ9NHUrx544iTojmO+8paIFF6WaFSh8rBB7 MdOZjSuwGIDqPzLxXe6Hps17Vu0k2X/K/fkeirOjt1yAj7t5XAYtTBgesJU8creSZ3x6 f4RA== 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=Mzdr9yLs5nJE6hBnuYkAGMUAiDKHyEEnR54GqF1pxrw=; b=A76ocBF5esvW3htKf91YqrAbm2KY+MFG41EjJcek8tu5MqhgONW/OXhp1ugt4iGNkg Gjh2Ty7PFrNygSTAtDXVToGNer+ndly6gYxtWb3j5ZtvPA0JCRhYSO76uyD6DuUNqkOX j0xqBXgKsVFbQopVDsDtHdbxmnSytLz7IH4lXrPvNhBE41tzBWe29bUWZjnyPW5n8LcY qk915h6pph1SyVQbZAsB3KXljgDkWZhf+7voDzV4JvYc33Q0IqcRvRwcZIZbKKVpIBOa K9oUh5YQiNE+uBL57rZG1Q5SNuswNhHgDUTzsjHbYzx2XsHxm3DOJ/WFaAPeKu2F0+kq mQgw== X-Gm-Message-State: APjAAAWrYx1sfMgOfCWLXkVldUu+sdavRCqcZZNTHzsZ9+VCuomGsDXo oNOku3dNaYU7PvIO/rIxXc8knurSJEo1wHJDpa/9A2cWX/E5pL1y/M42DIGZ97taA2vTjx31C4m mVDpp4UoNu7scnM4e7rwtCrYPF98= X-Received: by 2002:a24:4202:: with SMTP id i2mr1163068itb.85.1552548634627; Thu, 14 Mar 2019 00:30:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7DO2C54XadysxQeTsnDN7MdTtxbOmv8tvN+nTC1s5OmGx+9DNywZpdKtxiwqrX/K7/IcH7Q== X-Received: by 2002:a24:4202:: with SMTP id i2mr1163060itb.85.1552548634436; Thu, 14 Mar 2019 00:30:34 -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 n20sm5885439iom.5.2019.03.14.00.30.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 00:30:33 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Cc: pakki001@umn.edu, Ferenc Bakonyi , Bartlomiej Zolnierkiewicz , linux-nvidia@lists.surfsouth.com, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] video: hgafb: fix a NULL pointer dereference Date: Thu, 14 Mar 2019 02:30:27 -0500 Message-Id: <20190314073027.22337-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 When ioremap fails, hga_vram should not be dereferenced. The fix check the failure to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu --- drivers/video/fbdev/hgafb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/hgafb.c b/drivers/video/fbdev/hgafb.c index 463028543173..59e1cae57948 100644 --- a/drivers/video/fbdev/hgafb.c +++ b/drivers/video/fbdev/hgafb.c @@ -285,6 +285,8 @@ static int hga_card_detect(void) hga_vram_len = 0x08000; hga_vram = ioremap(0xb0000, hga_vram_len); + if (!hga_vram) + goto error; if (request_region(0x3b0, 12, "hgafb")) release_io_ports = 1;