From patchwork Thu Apr 15 10:22:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 421726 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6d12:0:0:0:0 with SMTP id m18csp572825ejr; Thu, 15 Apr 2021 03:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZYpPwws3zGYWJZ3UfbXQkCo1EUDtdLLUX/JqWvZ6rPrLml8MqKSz3mFlXhmNdsw242jfS X-Received: by 2002:a63:30c1:: with SMTP id w184mr2791020pgw.230.1618482154361; Thu, 15 Apr 2021 03:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618482154; cv=none; d=google.com; s=arc-20160816; b=skXNxWG8SVDAJrn+i9oTAsrg3hP/5git4j3+c+K4UwbSIUGj5FEZZ8L1pKx4SiP0FC rZ9iSifgFAOCSi8Zkcc3SQB1pKRxDmOlbtLPwtlcaIhVdwLhwtYuaANR6thmjmPNXdc6 8IAfjRz9gGffhab6bOBPpShnl7hTJye0ORZJJkwfAlsa3MlPuoYl9nYVInYoBlNKdbPa tN7oOxniNgzyaHztRQ6z6dfwKw3OX7Z6qVvTPOdhDaZGMkYvRXmgRZGJUUV33rW/TCTX pJtVsKhMsLhKIj2bzHCjswUpvvQAQngVkUFPdovJxxQhfPTjEVUVv9gU5/qCLpGtee8f gKPg== 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 :message-id:date:subject:cc:to:from; bh=lbe1C2dktIJq4eyUoun2RS5d/Til4ZrwpsCyV7R3Kyo=; b=n9KqRc+lBWXWF/O4kR6SBpQlu+0wf7AbFGuQrVmikvA1YSyeZqDQQIoULZUZR7MaNg 3xogl1ouUikjF5ksP1hmTG3r6sMcbTBsIir5aBMdgC13wCdBmTG09JhU7Ls1wKbFhAKe C7wB73u4ZjHq0+u5R8b8R1d3udsGaicN+R2OuhvEJU/FIZ+TWq7MJoeR6mkDL9IkkVpA xC29c0JykFb9Taz34Xl+/ziS2WqXqEXXx0ghTji7QmiC5Cx5oLRwBgQmttiGmJPMqEBg /p0fECuWkKwU67kUP4IlDbMiuN7MTGU05Vf0ck8rZ/GsbdbGijw21wUC2iGyh/l1fjjv 7zbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-fbdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si2834379plo.141.2021.04.15.03.22.34 for ; Thu, 15 Apr 2021 03:22:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-fbdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-fbdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbhDOKW4 (ORCPT ); Thu, 15 Apr 2021 06:22:56 -0400 Received: from foss.arm.com ([217.140.110.172]:42520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbhDOKWz (ORCPT ); Thu, 15 Apr 2021 06:22:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 727AB12FC; Thu, 15 Apr 2021 03:22:32 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D2AC3F73B; Thu, 15 Apr 2021 03:22:31 -0700 (PDT) From: Sudeep Holla To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, Kai-Heng Feng , Alex Deucher , Thomas Zimmermann , Peter Jones Subject: [PATCH] efifb: Fix runtime pm calls for non PCI efifb device Date: Thu, 15 Apr 2021 11:22:24 +0100 Message-Id: <20210415102224.2764054-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Commit a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0") added runtime pm calls to probe and remove routines to ensure the PCI device for efifb stays in D0 state. However not ever efifb is based on PCI device and efifb_pci_dev can be NULL if that is the case. In such cases, we will get a boot splat like below due to NULL dereference: -->8 Console: switching to colour frame buffer device 240x67 fb0: EFI VGA frame buffer device Unable to handle kernel NULL pointer dereference at virtual address 0000000000000270 Mem abort info: ESR = 0x96000004 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000004 CM = 0, WnR = 0 [0000000000000270] user address but active_mm is swapper Internal error: Oops: 96000004 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc7-next-20210413 #1 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) pc : pm_runtime_drop_link+0x12c/0x338 lr : efifb_probe+0x7bc/0x7f0 Call trace: pm_runtime_drop_link+0x12c/0x338 efifb_probe+0x7bc/0x7f0 platform_probe+0x68/0xd8 really_probe+0xe4/0x3a8 driver_probe_device+0x64/0xc8 device_driver_attach+0x74/0x80 __driver_attach+0x64/0xf0 bus_for_each_dev+0x70/0xc0 driver_attach+0x24/0x30 bus_add_driver+0x150/0x1f8 driver_register+0x64/0x120 __platform_driver_register+0x28/0x38 efifb_driver_init+0x1c/0x28 do_one_initcall+0x48/0x2b0 kernel_init_freeable+0x1e8/0x258 kernel_init+0x14/0x118 ret_from_fork+0x10/0x30 Code: 88027c01 35ffffa2 17fff706 f9800051 (885f7c40) ---[ end trace 17d8da630bf8ff77 ]--- Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b -->8 Fix the issue by checking for non-NULL efifb_pci_dev before dereferencing for runtime pm calls in probe and remove routines. Fixes: a6c0fd3d5a8b ("efifb: Ensure graphics device for efifb stays at PCI D0") Cc: Kai-Heng Feng Cc: Alex Deucher Cc: Thomas Zimmermann Cc: Peter Jones Signed-off-by: Sudeep Holla --- drivers/video/fbdev/efifb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index f58a545b3bf3..8ea8f079cde2 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -575,7 +575,8 @@ static int efifb_probe(struct platform_device *dev) goto err_fb_dealoc; } fb_info(info, "%s frame buffer device\n", info->fix.id); - pm_runtime_get_sync(&efifb_pci_dev->dev); + if (efifb_pci_dev) + pm_runtime_get_sync(&efifb_pci_dev->dev); return 0; err_fb_dealoc: @@ -602,7 +603,8 @@ static int efifb_remove(struct platform_device *pdev) unregister_framebuffer(info); sysfs_remove_groups(&pdev->dev.kobj, efifb_groups); framebuffer_release(info); - pm_runtime_put(&efifb_pci_dev->dev); + if (efifb_pci_dev) + pm_runtime_put(&efifb_pci_dev->dev); return 0; }