linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/msm/mdp5: Add check for kzalloc
@ 2022-12-06  7:48 Jiasheng Jiang
  2023-01-24  8:26 ` Dmitry Baryshkov
  2023-01-26 19:01 ` Dmitry Baryshkov
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2022-12-06  7:48 UTC (permalink / raw)
  To: robdclark, quic_abhinavk, dmitry.baryshkov, sean, airlied,
	daniel, quic_jesszhan, ville.syrjala, yang.lee
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel, Jiasheng Jiang

As kzalloc may fail and return NULL pointer,
it should be better to check the return value
in order to avoid the NULL pointer dereference.

Fixes: 1cff7440a86e ("drm/msm: Convert to using __drm_atomic_helper_crtc_reset() for reset.")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
index e86421c69bd1..86036dd4e1e8 100644
--- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
@@ -1139,7 +1139,10 @@ static void mdp5_crtc_reset(struct drm_crtc *crtc)
 	if (crtc->state)
 		mdp5_crtc_destroy_state(crtc, crtc->state);
 
-	__drm_atomic_helper_crtc_reset(crtc, &mdp5_cstate->base);
+	if (mdp5_cstate)
+		__drm_atomic_helper_crtc_reset(crtc, &mdp5_cstate->base);
+	else
+		__drm_atomic_helper_crtc_reset(crtc, NULL);
 }
 
 static const struct drm_crtc_funcs mdp5_crtc_no_lm_cursor_funcs = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/mdp5: Add check for kzalloc
  2022-12-06  7:48 [PATCH] drm/msm/mdp5: Add check for kzalloc Jiasheng Jiang
@ 2023-01-24  8:26 ` Dmitry Baryshkov
  2023-01-26 19:01 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2023-01-24  8:26 UTC (permalink / raw)
  To: Jiasheng Jiang, robdclark, quic_abhinavk, sean, airlied, daniel,
	quic_jesszhan, ville.syrjala, yang.lee
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel

On 06/12/2022 09:48, Jiasheng Jiang wrote:
> As kzalloc may fail and return NULL pointer,
> it should be better to check the return value
> in order to avoid the NULL pointer dereference.
> 
> Fixes: 1cff7440a86e ("drm/msm: Convert to using __drm_atomic_helper_crtc_reset() for reset.")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>   drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/mdp5: Add check for kzalloc
  2022-12-06  7:48 [PATCH] drm/msm/mdp5: Add check for kzalloc Jiasheng Jiang
  2023-01-24  8:26 ` Dmitry Baryshkov
@ 2023-01-26 19:01 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2023-01-26 19:01 UTC (permalink / raw)
  To: robdclark, quic_abhinavk, sean, airlied, daniel, quic_jesszhan,
	ville.syrjala, yang.lee, Jiasheng Jiang
  Cc: linux-arm-msm, dri-devel, freedreno, linux-kernel


On Tue, 06 Dec 2022 15:48:19 +0800, Jiasheng Jiang wrote:
> As kzalloc may fail and return NULL pointer,
> it should be better to check the return value
> in order to avoid the NULL pointer dereference.
> 
> 

Applied, thanks!

[1/1] drm/msm/mdp5: Add check for kzalloc
      https://gitlab.freedesktop.org/lumag/msm/-/commit/13fcfcb2a9a4

Best regards,
-- 
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-26 19:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-06  7:48 [PATCH] drm/msm/mdp5: Add check for kzalloc Jiasheng Jiang
2023-01-24  8:26 ` Dmitry Baryshkov
2023-01-26 19:01 ` Dmitry Baryshkov

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).