drm/arm/malidp: fix a possible null pointer dereference
Subsystems (3)
PATCH v2 1/1 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.
---
V2:
* In patch V2, we additionally set connector->state to NULL. In this way we can ensure that there is no state pointing to freed memory. Thanks to Liviu Dudau for helpful suggestion.
--- drivers/gpu/drm/arm/malidp_mw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_mw.c +4 -1
@@ -72,7 +72,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
Signature · 1 line
2.34.1
Quoted 7 lines · Huai-Yuan Liu
In
malidp_mw_connector_reset, new memory is allocated with kzalloc, but no check is performed. In order to prevent null pointer dereferencing, ensure thatmw_stateis checked before calling__drm_atomic_helper_connector_reset.Fixes 8cbc5caf36ef ("drm: mali-dp: Add writeback connector")Signed-off-by Huai-Yuan Liu <[email protected]>
Thanks for the patch. I will pull it into drm-misc-fixes before the end of the week.
Best regards,
Liviu
Quoted 28 lines
---
V2:
* In patch V2, we additionally setconnector->stateto NULL. In this way we can ensure that there is no state pointing to freed memory. Thanks to Liviu Dudau for helpful suggestion.--- drivers/gpu/drm/arm/malidp_mw.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/arm/malidp_mw.c +4
-1@@ -72,7 +72,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_statusSignature · 1 line
2.34.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯