Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/ast: potential dereference of null pointer

The return value of kzalloc() needs to be checked.
To avoid use of null pointer '&ast_state->base' in case of the
failure of alloc.

Fixes: f0adbc382b8b ("drm/ast: Allocate initial CRTC state of the correct size")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20211214014126.2211535-1-jiasheng@iscas.ac.cn

authored by

Jiasheng Jiang and committed by
Thomas Zimmermann
fea3fdf9 5cf06065

+4 -1
+4 -1
drivers/gpu/drm/ast/ast_mode.c
··· 1121 1121 if (crtc->state) 1122 1122 crtc->funcs->atomic_destroy_state(crtc, crtc->state); 1123 1123 1124 - __drm_atomic_helper_crtc_reset(crtc, &ast_state->base); 1124 + if (ast_state) 1125 + __drm_atomic_helper_crtc_reset(crtc, &ast_state->base); 1126 + else 1127 + __drm_atomic_helper_crtc_reset(crtc, NULL); 1125 1128 } 1126 1129 1127 1130 static struct drm_crtc_state *