Commit 9fa12045 authored by Laurent Pinchart's avatar Laurent Pinchart

drm: rcar-du: Fix leak of CMM platform device reference

The device references acquired by of_find_device_by_node() are not
released by the driver. Fix this by registering a cleanup action.

Fixes: 8de707ae ("drm: rcar-du: kms: Initialize CMM instances")
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
parent 8d7d33f6
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <drm/drm_fb_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <drm/drm_vblank.h> #include <drm/drm_vblank.h>
...@@ -726,8 +727,12 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) ...@@ -726,8 +727,12 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
* disabled: return 0 and let the DU continue probing. * disabled: return 0 and let the DU continue probing.
*/ */
ret = rcar_cmm_init(pdev); ret = rcar_cmm_init(pdev);
if (ret) if (ret) {
platform_device_put(pdev);
return ret == -ENODEV ? 0 : ret; return ret == -ENODEV ? 0 : ret;
}
rcdu->cmms[i] = pdev;
/* /*
* Enforce suspend/resume ordering by making the CMM a provider * Enforce suspend/resume ordering by making the CMM a provider
...@@ -739,13 +744,20 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu) ...@@ -739,13 +744,20 @@ static int rcar_du_cmm_init(struct rcar_du_device *rcdu)
"Failed to create device link to CMM%u\n", i); "Failed to create device link to CMM%u\n", i);
return -EINVAL; return -EINVAL;
} }
rcdu->cmms[i] = pdev;
} }
return 0; return 0;
} }
static void rcar_du_modeset_cleanup(struct drm_device *dev, void *res)
{
struct rcar_du_device *rcdu = to_rcar_du_device(dev);
unsigned int i;
for (i = 0; i < ARRAY_SIZE(rcdu->cmms); ++i)
platform_device_put(rcdu->cmms[i]);
}
int rcar_du_modeset_init(struct rcar_du_device *rcdu) int rcar_du_modeset_init(struct rcar_du_device *rcdu)
{ {
static const unsigned int mmio_offsets[] = { static const unsigned int mmio_offsets[] = {
...@@ -766,6 +778,10 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) ...@@ -766,6 +778,10 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
if (ret) if (ret)
return ret; return ret;
ret = drmm_add_action(&rcdu->ddev, rcar_du_modeset_cleanup, NULL);
if (ret)
return ret;
dev->mode_config.min_width = 0; dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0; dev->mode_config.min_height = 0;
dev->mode_config.normalize_zpos = true; dev->mode_config.normalize_zpos = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment