aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2018-01-17 16:55:29 -0500
committerLiviu Dudau <Liviu.Dudau@arm.com>2018-03-14 07:38:02 -0400
commit084ffbd7fd147ce6e114d82298c84f143d4fff7f (patch)
tree30c85a60e3348424083ad8b4f41108cc1d863a1d
parentd862b2d622530d14072f3ae417a0525fb7361410 (diff)
drm: arm: malidp: Don't destroy planes manually in error handlers
The top-level error handler calls drm_mode_config_cleanup() which will destroy all planes. There's no need to destroy them manually in lower error handlers. As plane cleanup is now handled entirely by drm_mode_config_cleanup(), we must ensure that the plane .destroy() handler frees allocated memory for the plane object that was freed by malidp_de_planes_destroy(). Do so by replacing the call to devm_kfree() in the .destroy() handler by kfree(). devm_kfree() is currently a no-op as the plane memory is allocated with kzalloc(), not devm_kzalloc(). Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Liviu Dudau <liviu.dudau@arm.com>
-rw-r--r--drivers/gpu/drm/arm/malidp_crtc.c10
-rw-r--r--drivers/gpu/drm/arm/malidp_drv.c1
-rw-r--r--drivers/gpu/drm/arm/malidp_drv.h1
-rw-r--r--drivers/gpu/drm/arm/malidp_planes.c13
4 files changed, 3 insertions, 22 deletions
diff --git a/drivers/gpu/drm/arm/malidp_crtc.c b/drivers/gpu/drm/arm/malidp_crtc.c
index 7b952559fc43..fcc62bc60f6a 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -531,14 +531,13 @@ int malidp_crtc_init(struct drm_device *drm)
531 531
532 if (!primary) { 532 if (!primary) {
533 DRM_ERROR("no primary plane found\n"); 533 DRM_ERROR("no primary plane found\n");
534 ret = -EINVAL; 534 return -EINVAL;
535 goto crtc_cleanup_planes;
536 } 535 }
537 536
538 ret = drm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL, 537 ret = drm_crtc_init_with_planes(drm, &malidp->crtc, primary, NULL,
539 &malidp_crtc_funcs, NULL); 538 &malidp_crtc_funcs, NULL);
540 if (ret) 539 if (ret)
541 goto crtc_cleanup_planes; 540 return ret;
542 541
543 drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs); 542 drm_crtc_helper_add(&malidp->crtc, &malidp_crtc_helper_funcs);
544 drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE); 543 drm_mode_crtc_set_gamma_size(&malidp->crtc, MALIDP_GAMMA_LUT_SIZE);
@@ -548,9 +547,4 @@ int malidp_crtc_init(struct drm_device *drm)
548 malidp_se_set_enh_coeffs(malidp->dev); 547 malidp_se_set_enh_coeffs(malidp->dev);
549 548
550 return 0; 549 return 0;
551
552crtc_cleanup_planes:
553 malidp_de_planes_destroy(drm);
554
555 return ret;
556} 550}
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 3c628e43bf25..2b26f40a9786 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -278,7 +278,6 @@ static int malidp_init(struct drm_device *drm)
278 278
279static void malidp_fini(struct drm_device *drm) 279static void malidp_fini(struct drm_device *drm)
280{ 280{
281 malidp_de_planes_destroy(drm);
282 drm_mode_config_cleanup(drm); 281 drm_mode_config_cleanup(drm);
283} 282}
284 283
diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h
index c2375bb49619..c70989b93387 100644
--- a/drivers/gpu/drm/arm/malidp_drv.h
+++ b/drivers/gpu/drm/arm/malidp_drv.h
@@ -60,7 +60,6 @@ struct malidp_crtc_state {
60#define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base) 60#define to_malidp_crtc_state(x) container_of(x, struct malidp_crtc_state, base)
61 61
62int malidp_de_planes_init(struct drm_device *drm); 62int malidp_de_planes_init(struct drm_device *drm);
63void malidp_de_planes_destroy(struct drm_device *drm);
64int malidp_crtc_init(struct drm_device *drm); 63int malidp_crtc_init(struct drm_device *drm);
65 64
66/* often used combination of rotational bits */ 65/* often used combination of rotational bits */
diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c
index 1a2992f178e5..648e97693df9 100644
--- a/drivers/gpu/drm/arm/malidp_planes.c
+++ b/drivers/gpu/drm/arm/malidp_planes.c
@@ -64,7 +64,7 @@ static void malidp_de_plane_destroy(struct drm_plane *plane)
64 64
65 drm_plane_helper_disable(plane); 65 drm_plane_helper_disable(plane);
66 drm_plane_cleanup(plane); 66 drm_plane_cleanup(plane);
67 devm_kfree(plane->dev->dev, mp); 67 kfree(mp);
68} 68}
69 69
70/* 70/*
@@ -449,18 +449,7 @@ int malidp_de_planes_init(struct drm_device *drm)
449 return 0; 449 return 0;
450 450
451cleanup: 451cleanup:
452 malidp_de_planes_destroy(drm);
453 kfree(formats); 452 kfree(formats);
454 453
455 return ret; 454 return ret;
456} 455}
457
458void malidp_de_planes_destroy(struct drm_device *drm)
459{
460 struct drm_plane *p, *pt;
461
462 list_for_each_entry_safe(p, pt, &drm->mode_config.plane_list, head) {
463 drm_plane_cleanup(p);
464 kfree(p);
465 }
466}