Message ID | 20230829131941.3353439-1-mwalle@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/mediathek: fix kernel oops if no crtc is found | expand |
On Tue, Aug 29, 2023 at 03:19:40PM +0200, Michael Walle wrote: > drm_crtc_from_index(0) might return NULL if there are not CRTCs Typo: not -> no > 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> There's also a typo in the commit subject: mediathek -> mediatek. But regardless, Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> (tested that the patch fixes the oops on mt8195-cherry-tomato when no display pipeline is available) Thanks, Nícolas
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");
drm_crtc_from_index(0) might return NULL if there are not 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> --- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)