diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-07-27 04:42:54 -0400 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-10-19 18:36:14 -0400 |
commit | a32a3c800ca3ae822dfdd29f5b7ef81fbf970612 (patch) | |
tree | 4314b1a6edf36defef93ed2d56a46f2a9043edaa /drivers | |
parent | f4f0fb7949a9e55f4f3429381b8b92372038b6cd (diff) |
drm: rcar-du: Fix plane state free in plane reset handler
The plane reset handler frees the plane state and allocates a new
default state, but when doing so attempt to free the plane state using
the base plane state pointer instead of casting it to the
driver-specific state object that has been allocated. Fix it by using
the rcar_du_plane_atomic_destroy_state() function to destroy the plane
state instead of duplicating the code.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_plane.c | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index c66986414bb4..ffa583712cd9 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c | |||
@@ -273,29 +273,6 @@ static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = { | |||
273 | .atomic_update = rcar_du_plane_atomic_update, | 273 | .atomic_update = rcar_du_plane_atomic_update, |
274 | }; | 274 | }; |
275 | 275 | ||
276 | static void rcar_du_plane_reset(struct drm_plane *plane) | ||
277 | { | ||
278 | struct rcar_du_plane_state *state; | ||
279 | |||
280 | if (plane->state && plane->state->fb) | ||
281 | drm_framebuffer_unreference(plane->state->fb); | ||
282 | |||
283 | kfree(plane->state); | ||
284 | plane->state = NULL; | ||
285 | |||
286 | state = kzalloc(sizeof(*state), GFP_KERNEL); | ||
287 | if (state == NULL) | ||
288 | return; | ||
289 | |||
290 | state->hwindex = -1; | ||
291 | state->alpha = 255; | ||
292 | state->colorkey = RCAR_DU_COLORKEY_NONE; | ||
293 | state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; | ||
294 | |||
295 | plane->state = &state->state; | ||
296 | plane->state->plane = plane; | ||
297 | } | ||
298 | |||
299 | static struct drm_plane_state * | 276 | static struct drm_plane_state * |
300 | rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane) | 277 | rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane) |
301 | { | 278 | { |
@@ -322,6 +299,28 @@ static void rcar_du_plane_atomic_destroy_state(struct drm_plane *plane, | |||
322 | kfree(to_rcar_plane_state(state)); | 299 | kfree(to_rcar_plane_state(state)); |
323 | } | 300 | } |
324 | 301 | ||
302 | static void rcar_du_plane_reset(struct drm_plane *plane) | ||
303 | { | ||
304 | struct rcar_du_plane_state *state; | ||
305 | |||
306 | if (plane->state) { | ||
307 | rcar_du_plane_atomic_destroy_state(plane, plane->state); | ||
308 | plane->state = NULL; | ||
309 | } | ||
310 | |||
311 | state = kzalloc(sizeof(*state), GFP_KERNEL); | ||
312 | if (state == NULL) | ||
313 | return; | ||
314 | |||
315 | state->hwindex = -1; | ||
316 | state->alpha = 255; | ||
317 | state->colorkey = RCAR_DU_COLORKEY_NONE; | ||
318 | state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; | ||
319 | |||
320 | plane->state = &state->state; | ||
321 | plane->state->plane = plane; | ||
322 | } | ||
323 | |||
325 | static int rcar_du_plane_atomic_set_property(struct drm_plane *plane, | 324 | static int rcar_du_plane_atomic_set_property(struct drm_plane *plane, |
326 | struct drm_plane_state *state, | 325 | struct drm_plane_state *state, |
327 | struct drm_property *property, | 326 | struct drm_property *property, |