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

drm/arm/malidp: fix a possible null pointer dereference

In malidp_mw_connector_reset, new memory is allocated with kzalloc, but
no check is performed. In order to prevent null pointer dereferencing,
ensure that mw_state is checked before calling
__drm_atomic_helper_connector_reset.

Fixes: 8cbc5caf36ef ("drm: mali-dp: Add writeback connector")
Signed-off-by: Huai-Yuan Liu <qq810974084@gmail.com>
Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240407063053.5481-1-qq810974084@gmail.com

authored by

Huai-Yuan Liu and committed by
Liviu Dudau
a1f95aed 42118c5f

+4 -1
+4 -1
drivers/gpu/drm/arm/malidp_mw.c
··· 72 72 __drm_atomic_helper_connector_destroy_state(connector->state); 73 73 74 74 kfree(connector->state); 75 - __drm_atomic_helper_connector_reset(connector, &mw_state->base); 75 + connector->state = NULL; 76 + 77 + if (mw_state) 78 + __drm_atomic_helper_connector_reset(connector, &mw_state->base); 76 79 } 77 80 78 81 static enum drm_connector_status