]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/arm/malidp: fix a possible null pointer dereference
authorHuai-Yuan Liu <qq810974084@gmail.com>
Sun, 7 Apr 2024 06:30:53 +0000 (14:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:29 +0000 (13:39 +0200)
[ Upstream commit a1f95aede6285dba6dd036d907196f35ae3a11ea ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/arm/malidp_mw.c

index f5847a79dd7e8712c28e4060709207faf4e358ca..0720b2197c4e78569791fe7f1d5b475ae017fdc7 100644 (file)
@@ -70,7 +70,10 @@ static void malidp_mw_connector_reset(struct drm_connector *connector)
                __drm_atomic_helper_connector_destroy_state(connector->state);
 
        kfree(connector->state);
-       __drm_atomic_helper_connector_reset(connector, &mw_state->base);
+       connector->state = NULL;
+
+       if (mw_state)
+               __drm_atomic_helper_connector_reset(connector, &mw_state->base);
 }
 
 static enum drm_connector_status