aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShailendra Verma <shailendra.v@samsung.com>2016-11-11 08:35:00 -0500
committerLiviu Dudau <Liviu.Dudau@arm.com>2017-01-23 04:46:24 -0500
commit94d8b9b75c6118075ed54ad2fa0bea03c0f27145 (patch)
treeba120c37956ee714f3663c0be411ae3357b7bcf8
parentf0493e653f9679114d1dfd54ab88b54ce95576e1 (diff)
drm/arm/malidp: Fix possible dereference of NULL
There is possible deference of NULL pointer on return of malidp_duplicate_plane_state() if kmalloc fails. Check the returned kmalloc pointer before continuing. Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com> [cleaned up the code and re-formatted the commit message] Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
-rw-r--r--drivers/gpu/drm/arm/malidp_planes.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index eff2fe47e26a..d1cc15724dc3 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -67,13 +67,14 @@ drm_plane_state *malidp_duplicate_plane_state(struct drm_plane *plane)
67 return NULL; 67 return NULL;
68 68
69 state = kmalloc(sizeof(*state), GFP_KERNEL); 69 state = kmalloc(sizeof(*state), GFP_KERNEL);
70 if (state) { 70 if (!state)
71 m_state = to_malidp_plane_state(plane->state); 71 return NULL;
72 __drm_atomic_helper_plane_duplicate_state(plane, &state->base); 72
73 state->rotmem_size = m_state->rotmem_size; 73 m_state = to_malidp_plane_state(plane->state);
74 state->format = m_state->format; 74 __drm_atomic_helper_plane_duplicate_state(plane, &state->base);
75 state->n_planes = m_state->n_planes; 75 state->rotmem_size = m_state->rotmem_size;
76 } 76 state->format = m_state->format;
77 state->n_planes = m_state->n_planes;
77 78
78 return &state->base; 79 return &state->base;
79} 80}