Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2501882rdb; Thu, 21 Sep 2023 23:42:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEE/m52S8LcTBD09T+0G/gPzQm3FNiL6ERZHU0LlcmMFiPa5iyFdg7823eYTGJx9r5070AG X-Received: by 2002:a05:6808:210d:b0:3ae:16aa:8ba9 with SMTP id r13-20020a056808210d00b003ae16aa8ba9mr1555358oiw.30.1695364945408; Thu, 21 Sep 2023 23:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695364945; cv=none; d=google.com; s=arc-20160816; b=gpzJ2yRbENLsTRgBnDIDIR1XIYQSrOEXlCBWETgmfiVvRHQ7JcWtQqkxRLHLHQeIv3 nCM+4NY91Q7wK18in1ngD8DdQDA2k+/WTt3LGunDtiU1Arl4Y4JoOuU8tSp9+GBxY+OF O2hTvoEto4pDQtHzqJM8MbCwaSz6LlvETEqAFc129ZHZGP31a5aeKE2kPQHQy4Hi+llE rQc06rsZcEd6OWtQv+/vIYXfkubpcNC3MUU8GoPLB4wRpnX9Z32hVOUSrIjIf0bNz3Xr VzB6kZ8eWaq50aAM4qSOzuXdlP46ijWCbkxIT8CXuzY8BoDJsNx66hNV0IMJZZIC9yN8 EDHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=wl90tBKKO3bfptskJ3yz8Ad+tSM8Utlfmo70JdbbbAA=; fh=jxoZ5GPLoCuf2flToHim08YJ9wDk4PKBOQMr/bkfXNM=; b=fVJPiXiPH66tDpejNmhvIBDUqLRr74gluojM8e6r83rU9c7iQMqFHvYV05ku1L+GC9 i8AFVsndtZGHZZ80+N27w1Lkwz9YbvdVzqupoEOWyx7x8BDK45RsbcBHK3syH7sBuSk7 CbJBOzK3hFp5djbuk2PaEXQXS+jIgWoY0LGN5AueJF4zzOyB7aYrTCxNuQ0jKRL4PXaj ytc3ZRL4wsOfcuJwSMKNw1H4fZkDMeTBRLh96Ov1BfCJ3wqTVNLC/9RUS05rP/GwU6G5 f05SzUXbb1w2vL96gLV80zevXSQTTteB/trR5QDsouOVkBxLABT5dAUP+3LeXadr+C+W NQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Dzv0gpQS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id v70-20020a638949000000b0056cab36f3e1si3138353pgd.221.2023.09.21.23.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 23:42:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Dzv0gpQS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C758D8374E5C; Thu, 21 Sep 2023 14:16:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232689AbjIUVQe (ORCPT + 99 others); Thu, 21 Sep 2023 17:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233219AbjIUVP2 (ORCPT ); Thu, 21 Sep 2023 17:15:28 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2D65253 for ; Thu, 21 Sep 2023 10:08:14 -0700 (PDT) Received: from [192.168.0.125] (unknown [82.76.24.202]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 542A566072EE; Thu, 21 Sep 2023 10:22:51 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695288173; bh=5h61+8nLC/rHN8t6PmIBUe2/aZ2dOAIEsl5dm5eSgJA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Dzv0gpQSDo0rKOZzDlhbND/2kK6VC1bMm0YlWY+r9vdq/Sfg2whf1875ZtdTQwOks cg0jKDZaJ87PPpjE4cgeq2G2kaw3ybXKOb4HF+EkTwlzlhu69qyisPOAgw/Ek8YgaA r2ILSPR22QLBi767iiaKmTBntRz7DSovd57aM5Tt2N2d3XixEOrz9vs5eftTeUW0ls aV0vcUGCtqZLJ43Yn6sowhzHcyIkjB13XAppWge1fr/FBMMSq88G5U1D7Uau42E+NV k05eDgRjS9fftNKPYsvV9+g4c6fs3Y6fWs+ccTlofX+ujDI/ueRmwuh6rc4OL/De5X MJI+pV4OOqlBg== Message-ID: <3a9a9d52-0db9-360e-55f7-78753428ee7f@collabora.com> Date: Thu, 21 Sep 2023 12:22:47 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v4 1/2] drm/mediatek: fix kernel oops if no crtc is found Content-Language: en-US To: Michael Walle , =?UTF-8?Q?N=c3=adcolas_F_=2e_R_=2e_A_=2e_Prado?= , Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , AngeloGioacchino Del Regno Cc: Jitao Shi , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Nancy . Lin" , linux-mediatek@lists.infradead.org, Stu Hsieh , linux-arm-kernel@lists.infradead.org References: <20230905084922.3908121-1-mwalle@kernel.org> From: Eugen Hristev In-Reply-To: <20230905084922.3908121-1-mwalle@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 21 Sep 2023 14:16:54 -0700 (PDT) On 9/5/23 11:49, Michael Walle wrote: > drm_crtc_from_index(0) might return NULL if there are no CRTCs > registered at all which will lead to a kernel oops in > mtk_drm_crtc_dma_dev_get(). Add the missing return value check. > > Fixes: 0d9eee9118b7 ("drm/mediatek: Add drm ovl_adaptor sub driver for MT8195") > Signed-off-by: Michael Walle > Reviewed-by: NĂ­colas F. R. A. Prado > Tested-by: NĂ­colas F. R. A. Prado > Reviewed-by: AngeloGioacchino Del Regno I tried this patch as well, hit the crash during my tests. I also reviewed your changes Tested-by: Eugen Hristev Reviewed-by: Eugen Hristev Eugen > --- > v4: > - collected tags > v3: > - none > v2: > - collected tags > - fixed typos > --- > drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > index 93552d76b6e7..2c582498817e 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c > @@ -420,6 +420,7 @@ static int mtk_drm_kms_init(struct drm_device *drm) > struct mtk_drm_private *private = drm->dev_private; > struct mtk_drm_private *priv_n; > struct device *dma_dev = NULL; > + struct drm_crtc *crtc; > int ret, i, j; > > if (drm_firmware_drivers_only()) > @@ -494,7 +495,9 @@ static int mtk_drm_kms_init(struct drm_device *drm) > } > > /* Use OVL device for all DMA memory allocations */ > - dma_dev = mtk_drm_crtc_dma_dev_get(drm_crtc_from_index(drm, 0)); > + crtc = drm_crtc_from_index(drm, 0); > + if (crtc) > + dma_dev = mtk_drm_crtc_dma_dev_get(crtc); > if (!dma_dev) { > ret = -ENODEV; > dev_err(drm->dev, "Need at least one OVL device\n");