diff options
author | Thierry Reding <treding@nvidia.com> | 2018-01-08 18:16:06 +0300 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2018-01-08 18:24:13 +0300 |
commit | 8f62142e490d761ceb92b55a7c05bb79294d6c6c (patch) | |
tree | f60600d739b1e26a0a2b4a96e33f06b1473fc08e /drivers/gpu/drm/tegra/dc.c | |
parent | 89f6501825b5bae3d4aaa2447636f9d3a4287a75 (diff) | |
download | linux-8f62142e490d761ceb92b55a7c05bb79294d6c6c.tar.xz |
drm/tegra: dc: Properly cleanup overlay planes
The first overlay plane can leak if initialization of the second overlay
plane fails. Fix this by properly destroying the first overlay plane on
error.
Suggested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu/drm/tegra/dc.c')
-rw-r--r-- | drivers/gpu/drm/tegra/dc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index 7a9c9ff8b4d7..b8403ed48285 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -937,20 +937,24 @@ static struct drm_plane *tegra_dc_add_shared_planes(struct drm_device *drm, static struct drm_plane *tegra_dc_add_planes(struct drm_device *drm, struct tegra_dc *dc) { - struct drm_plane *plane, *primary; + struct drm_plane *planes[2], *primary; unsigned int i; + int err; primary = tegra_primary_plane_create(drm, dc); if (IS_ERR(primary)) return primary; for (i = 0; i < 2; i++) { - plane = tegra_dc_overlay_plane_create(drm, dc, 1 + i); - if (IS_ERR(plane)) { - /* XXX tegra_plane_destroy() */ - drm_plane_cleanup(primary); - kfree(primary); - return plane; + planes[i] = tegra_dc_overlay_plane_create(drm, dc, 1 + i); + if (IS_ERR(planes[i])) { + err = PTR_ERR(planes[i]); + + while (i--) + tegra_plane_funcs.destroy(planes[i]); + + tegra_plane_funcs.destroy(primary); + return ERR_PTR(err); } } |