mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugen Hristev <eugen.hristev@collabora.com>
To: "Michael Walle" <mwalle@kernel.org>,
	"Nícolas F . R . A . Prado" <nfraprado@collabora.com>,
	"Chun-Kuang Hu" <chunkuang.hu@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: Jitao Shi <jitao.shi@mediatek.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	"Nancy . Lin" <nancy.lin@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Stu Hsieh <stu.hsieh@mediatek.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4 1/2] drm/mediatek: fix kernel oops if no crtc is found
Date: Thu, 21 Sep 2023 12:22:47 +0300	[thread overview]
Message-ID: <3a9a9d52-0db9-360e-55f7-78753428ee7f@collabora.com> (raw)
In-Reply-To: <20230905084922.3908121-1-mwalle@kernel.org>

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 <mwalle@kernel.org>
> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

I tried this patch as well, hit the crash during my tests. I also 
reviewed your changes

Tested-by: Eugen Hristev <eugen.hristev@collabora.com>
Reviewed-by: Eugen Hristev <eugen.hristev@collabora.com>

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");


  parent reply	other threads:[~2023-09-21 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05  8:49 Michael Walle
2023-09-05  8:49 ` [PATCH v4 2/2] drm/mediatek: dpi/dsi: fix possible_crtcs calculation Michael Walle
2023-09-05  9:01   ` AngeloGioacchino Del Regno
2023-11-21 14:44   ` Michael Walle
2023-11-23 15:33     ` Chun-Kuang Hu
2023-11-23 15:37       ` Michael Walle
2023-09-21  9:22 ` Eugen Hristev [this message]
2023-12-07 23:54 ` [PATCH v4 1/2] drm/mediatek: fix kernel oops if no crtc is found Chun-Kuang Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a9a9d52-0db9-360e-55f7-78753428ee7f@collabora.com \
    --to=eugen.hristev@collabora.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jitao.shi@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mwalle@kernel.org \
    --cc=nancy.lin@mediatek.com \
    --cc=nfraprado@collabora.com \
    --cc=p.zabel@pengutronix.de \
    --cc=stu.hsieh@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®