Skip to contentSkip to conversation

drm: mxsfb: Fix NULL pointer dereference crash on unload

PATCH Applied Marek Vasut 2 participants 2 messages Oct 16, 2021 – Oct 17, 2021

Subsystems (4)
lore
Share & tools
lore

Marek Vasut

author maintainer
#0 lore raw

PATCH 1/1 drm: mxsfb: Fix NULL pointer dereference crash on unload

The mxsfb->crtc.funcs may already be NULL when unloading the driver, in which case calling mxsfb_irq_disable() via drm_irq_uninstall() from mxsfb_unload() leads to NULL pointer dereference.

Since all we care about is masking the IRQ and mxsfb->base is still valid, just use that to clear and mask the IRQ.

Fixes ae1ed00932819 ("drm: mxsfb: Stop using DRM simple display pipeline helper")
Cc Daniel Abrecht <[email protected]>
Cc Emil Velikov <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Stefan Agner <[email protected]>
---
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/mxsfb_drv.c +5 -1
index ec0432fe1bdf..86d78634a979 100644
@@ -173,7 +173,11 @@ static void mxsfb_irq_disable(struct drm_device *drm)
 	struct mxsfb_drm_private *mxsfb = drm->dev_private;
 
 	mxsfb_enable_axi_clk(mxsfb);
-	mxsfb->crtc.funcs->disable_vblank(&mxsfb->crtc);
+
+	/* Disable and clear VBLANK IRQ */
+	writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR);
+	writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR);
+
 	mxsfb_disable_axi_clk(mxsfb);
 }
 
Signature · 1 line
2.33.0
Applied
#1 lore raw

Hi Marek,

Quoted 7 lines · Marek Vasut

The mxsfb->crtc.funcs may already be NULL when unloading the driver, in which case calling mxsfb_irq_disable() via drm_irq_uninstall() from mxsfb_unload() leads to NULL pointer dereference.

Since all we care about is masking the IRQ and mxsfb->base is still valid, just use that to clear and mask the IRQ.

Quoted 7 lines
Fixes ae1ed00932819 ("drm: mxsfb: Stop using DRM simple display pipeline helper")
Cc Daniel Abrecht <[email protected]>
Cc Emil Velikov <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Sam Ravnborg <[email protected]>
Cc Stefan Agner <[email protected]>

Applied to drm-misc-fixes.

Sam