]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/arm/malidp: Fix possible dereference of NULL
authorShailendra Verma <shailendra.v@samsung.com>
Fri, 11 Nov 2016 13:35:00 +0000 (13:35 +0000)
committerLiviu Dudau <Liviu.Dudau@arm.com>
Mon, 23 Jan 2017 09:46:24 +0000 (09:46 +0000)
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>
drivers/gpu/drm/arm/malidp_planes.c

index eff2fe47e26a71fad70c7c681de43dcc2fcfadd8..d1cc15724dc337f22b84e41fa169d3d7a2833997 100644 (file)
@@ -67,13 +67,14 @@ drm_plane_state *malidp_duplicate_plane_state(struct drm_plane *plane)
                return NULL;
 
        state = kmalloc(sizeof(*state), GFP_KERNEL);
-       if (state) {
-               m_state = to_malidp_plane_state(plane->state);
-               __drm_atomic_helper_plane_duplicate_state(plane, &state->base);
-               state->rotmem_size = m_state->rotmem_size;
-               state->format = m_state->format;
-               state->n_planes = m_state->n_planes;
-       }
+       if (!state)
+               return NULL;
+
+       m_state = to_malidp_plane_state(plane->state);
+       __drm_atomic_helper_plane_duplicate_state(plane, &state->base);
+       state->rotmem_size = m_state->rotmem_size;
+       state->format = m_state->format;
+       state->n_planes = m_state->n_planes;
 
        return &state->base;
 }