linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] drm/mediatek: fix kernel oops if no crtc is found
@ 2023-09-01 17:45 Michael Walle
  2023-09-01 17:45 ` [PATCH v3 2/2] drm/mediatek: dpi/dsi: fix possible_crtcs calculation Michael Walle
  2023-09-05  7:50 ` [PATCH v3 1/2] drm/mediatek: fix kernel oops if no crtc is found AngeloGioacchino Del Regno
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Walle @ 2023-09-01 17:45 UTC (permalink / raw)
  To: Nícolas F . R . A . Prado, Chun-Kuang Hu, Philipp Zabel,
	David Airlie, Daniel Vetter, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: Nancy . Lin, Frank Wunderlich, Jitao Shi, Stu Hsieh, dri-devel,
	linux-mediatek, linux-kernel, linux-arm-kernel, Michael Walle

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-09-05  8:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01 17:45 [PATCH v3 1/2] drm/mediatek: fix kernel oops if no crtc is found Michael Walle
2023-09-01 17:45 ` [PATCH v3 2/2] drm/mediatek: dpi/dsi: fix possible_crtcs calculation Michael Walle
2023-09-05  7:55   ` AngeloGioacchino Del Regno
2023-09-05  7:58     ` Michael Walle
2023-09-05  8:03       ` AngeloGioacchino Del Regno
2023-09-05  7:50 ` [PATCH v3 1/2] drm/mediatek: fix kernel oops if no crtc is found AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).