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: 9436149 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 CC8D26047D for ; Fri, 18 Nov 2016 10:08:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B9852950D for ; Fri, 18 Nov 2016 10:08:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9028429511; Fri, 18 Nov 2016 10:08:56 +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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A7BD2950D for ; Fri, 18 Nov 2016 10:08:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c7g4A-0003al-9E; Fri, 18 Nov 2016 10:06:42 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c7g44-0003XM-87; Fri, 18 Nov 2016 10:06:37 +0000 Received: by mail-wm0-x241.google.com with SMTP id a20so4480509wme.2; 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=CY+NBLJygfdzFeSC7yCD0HnMT0GDU+kPYCI6MEKRmdvTvjrlX4kWjICNWf2csHWaIG Bf/NzdmZ7CBsWKIN+6gtsQT8D43k4LO0VutgJ054DJI0RfIVdwdSlxquvnQfVeZ811Hb 970iSCCdBR/fcjyXbtCJYfU8C2gmkoLFW6GZzjdQ64uz46sxzX0L+P3wUhJ+G2P8nXGj L2+Np7B1D8lGZu2oZ4Gi8kZ8n2VUgvQy8RtAeQQTZM4vSooLj53mNUTMKi3cDLuWRhZQ 9hj15zjEsPdvoAGpK+XNNKmEZurImqq/j8oRPB8VjK2kiaEntZAht8ZCuk2nYQBiakLB wyfA== X-Gm-Message-State: ABUngvf0xfKZ16MkM1xozsly/OhPTq4pyfA+aRkk/V7Pqsl9P2pqboUUbPYGBGrvqkFoYQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161118_020636_483221_199253CB X-CRM114-Status: GOOD ( 16.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matthias.bgg@gmail.com, "moderated list:ARM/Mediatek SoC..." , "linux-arm-kernel@lists.infradead.org" , dri-devel , Linux Kernel Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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) {