mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
drm/mediatek: Check CRTC state before freeing
mtk_crtc_reset() destroys the current CRTC state only when crtc->state
is non-NULL, but it always converts crtc->state to struct mtk_crtc_state
and passes the result to kfree().
When reset is called without an existing state, container_of(NULL, ...)
does not produce NULL. Keep the mtk state free in the same crtc->state
guard as the helper state destruction.
This issue was found by a static analysis checker and confirmed by
manual source review.
Fixes: 2d267b8189 ("drm/mtk: Use __drm_atomic_helper_crtc_reset")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20260707150528.2270739-1-ruoyuw560@gmail.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
This commit is contained in:
committed by
Chun-Kuang Hu
parent
dc59e4fea9
commit
233a4d3a39
@@ -154,10 +154,10 @@ static void mtk_crtc_reset(struct drm_crtc *crtc)
|
||||
{
|
||||
struct mtk_crtc_state *state;
|
||||
|
||||
if (crtc->state)
|
||||
if (crtc->state) {
|
||||
__drm_atomic_helper_crtc_destroy_state(crtc->state);
|
||||
|
||||
kfree(to_mtk_crtc_state(crtc->state));
|
||||
kfree(to_mtk_crtc_state(crtc->state));
|
||||
}
|
||||
crtc->state = NULL;
|
||||
|
||||
state = kzalloc_obj(*state);
|
||||
|
||||
Reference in New Issue
Block a user