* Re: [PATCH] drm/arm/mali: Check for NULL pointer after calling kzalloc
@ 2022-01-14 9:54 Jiasheng Jiang
0 siblings, 0 replies; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-14 9:54 UTC (permalink / raw)
To: liviu.dudau, brian.starkey, airlied, daniel
Cc: dri-devel, linux-kernel, Jiasheng Jiang
Sorry, I just noticed that I have already sent the patch before and it has been reviewed.
Please ignore this one.
Sincerely thanks,
Jiang
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] drm/arm/mali: Check for NULL pointer after calling kzalloc
@ 2022-01-14 9:44 Jiasheng Jiang
0 siblings, 0 replies; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-14 9:44 UTC (permalink / raw)
To: liviu.dudau, brian.starkey, airlied, daniel
Cc: dri-devel, linux-kernel, Jiasheng Jiang
As the possible failure of the kzalloc(), mw_state could be NULL
pointer.
Therefore, it should be better to check it in order to avoid the
dereference of the NULL pointer, like the kzalloc() in
malidp_mw_connector_duplicate_state().
If fails, we can directly use the 'NULL' instead of the
'&mw_state->base' and __drm_atomic_helper_connector_reset() will deal
with it correctly.
Fixes: 8cbc5caf36ef ("drm: mali-dp: Add writeback connector")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/gpu/drm/arm/malidp_mw.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c
index f5847a79dd7e..96752353b5a1 100644
--- a/drivers/gpu/drm/arm/malidp_mw.c
+++ b/drivers/gpu/drm/arm/malidp_mw.c
@@ -70,7 +70,11 @@ 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);
+
+ if (!mw_state)
+ __drm_atomic_helper_connector_reset(connector, NULL);
+ else
+ __drm_atomic_helper_connector_reset(connector, &mw_state->base);
}
static enum drm_connector_status
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-14 9:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 9:54 [PATCH] drm/arm/mali: Check for NULL pointer after calling kzalloc Jiasheng Jiang
-- strict thread matches above, loose matches on Subject: below --
2022-01-14 9:44 Jiasheng Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).