From patchwork Fri Nov 18 10:06:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 9438381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74CE160469 for ; Sun, 20 Nov 2016 01:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6697A28465 for ; Sun, 20 Nov 2016 01:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A50E2902C; Sun, 20 Nov 2016 01:51:25 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 D9DD728465 for ; Sun, 20 Nov 2016 01:51:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 722296E104; Sun, 20 Nov 2016 01:51:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 229F26E937 for ; Fri, 18 Nov 2016 10:06:15 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m203so4454616wma.3 for ; Fri, 18 Nov 2016 02:06:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=w6Jk5VdnKOfNQZp//7JVO4J0T2zxvE8CeUF7q7r4+/U=; b=IKxDyHdtFzW0nVGz9nboiqdZYaz9jiEQOoVnCEf9I5qv5LgLNUQ/LvkLnzyZA1tumq bU0W3MGUXOKm0ZcuMMkq3RJn9oPcIjCKzolvHJ+TozlKGdvf1u/v9Ph/MzD6qKUrfbF1 iu90cZJLStDSrd1G1tgN06eoVKn8XMshKZMmpRRCfWOMn1qemLyrtKsZo5cepdcuC9Bl rH3c2vHtKy83GFLG/0yzEuD8KmcRo1MgP+taVUGfCA55+N6tr5f9uiJFbfce/gwxMV/u 3HT5YXy3sDdT0c7Kbc7eP0+2JZUK8iu3ZbVdS2N+Sui+WPNXlnaD2u5a/f2TkoRtkKr+ LnOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=w6Jk5VdnKOfNQZp//7JVO4J0T2zxvE8CeUF7q7r4+/U=; b=mOpD5fOPCIeY+3g+lT5TH6oT0sYBYI69sekZMaHlvez153aOgnE2b5ZlfewZiE8qyE q8gU3EHyZGLNmDrSCieKB5dsLpRvdu2vJ/rdqFTgjPsFtyIpRmes5vmoFuj/B01JAiv8 LpAyVjeU/kgr61NmMHBMeZ3XBD6Ipw248lRLPqNJTFtmuXF5RvsuKy9vz/BEIF9DceT6 5Gp3ilMRRbisClZD+mOazVj4hljUiDkWoybVAcFw17j/xvhldy3Whj0tCyPpNYJHg0VB RWY3N7HSt9T+EFAX2JJby3e80yKq9YvGPZPHQDxcz4cg/YbhkTwrCAahcVhH3srW/GaJ 4u8A== X-Gm-Message-State: ABUngveld3SxCz/cDmsr8vI03k1oyKsUb/SdXB3DgADT+5PaXJra30xa9ghOnqjJyA27sg== X-Received: by 10.28.35.205 with SMTP id j196mr9836846wmj.62.1479463573729; Fri, 18 Nov 2016 02:06:13 -0800 (PST) Received: from linux-gy6r.site (138.red-83-58-211.dynamicip.rima-tde.net. [83.58.211.138]) by smtp.gmail.com with ESMTPSA id cl6sm701187wjc.10.2016.11.18.02.06.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Nov 2016 02:06:12 -0800 (PST) To: CK Hu , Philipp Zabel , David Airlie From: Matthias Brugger Subject: [Resend PATCH] drm/mediatek: fix null pointer dereference Message-ID: <13893536-4b1f-4ff9-c265-971f08623ea5@gmail.com> Date: Fri, 18 Nov 2016 11:06:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-Mailman-Approved-At: Sun, 20 Nov 2016 01:50:52 +0000 Cc: matthias.bgg@gmail.com, "moderated list:ARM/Mediatek SoC..." , "linux-arm-kernel@lists.infradead.org" , dri-devel , Linux Kernel Mailing List X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The probe function requests the interrupt before initializing the ddp component. Which leads to a null pointer dereference at boot. Fix this by requesting the interrput after all components got initialized properly. Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.") Signed-off-by: Matthias Brugger --- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) dev_err(dev, "Failed to identify by alias: %d\n", comp_id); @@ -272,6 +265,13 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler, + IRQF_TRIGGER_NONE, dev_name(dev), priv); + if (ret < 0) { + dev_err(dev, "Failed to request irq %d: %d\n", irq, ret); + return ret; + } + ret = component_add(dev, &mtk_disp_ovl_component_ops); if (ret) dev_err(dev, "Failed to add component: %d\n", ret); diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c index 019b7ca..1e78159 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c @@ -250,13 +250,6 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev) if (irq < 0) return irq; - ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler, - IRQF_TRIGGER_NONE, dev_name(dev), priv); - if (ret < 0) { - dev_err(dev, "Failed to request irq %d: %d\n", irq, ret); - return ret; - } - comp_id = mtk_ddp_comp_get_id(dev->of_node, MTK_DISP_OVL); if (comp_id < 0) {