diff options
author | Thierry Reding <treding@nvidia.com> | 2018-05-04 15:08:49 +0200 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2018-05-17 14:03:30 +0200 |
commit | 230630bd3834af0ea6ec75354ec21819de148ee1 (patch) | |
tree | 81958a8af4835a89511b0b2a6910855f8e924045 /drivers/gpu/drm | |
parent | dd99b4b48833a55817d78a48034b606664b1fff8 (diff) |
drm/tegra: gr3d: Properly clean up resources
Failure to register the Tegra DRM client would leak the resources. Move
cleanup code to error unwinding gotos to fix that and share the cleanup
code with the other error paths.
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/tegra/gr3d.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c index ce5120683091..9303278efc1d 100644 --- a/drivers/gpu/drm/tegra/gr3d.c +++ b/drivers/gpu/drm/tegra/gr3d.c @@ -52,8 +52,9 @@ static int gr3d_init(struct host1x_client *client) client->syncpts[0] = host1x_syncpt_request(client, flags); if (!client->syncpts[0]) { - host1x_channel_put(gr3d->channel); - return -ENOMEM; + err = -ENOMEM; + dev_err(client->dev, "failed to request syncpoint: %d\n", err); + goto put; } if (tegra->domain) { @@ -65,15 +66,30 @@ static int gr3d_init(struct host1x_client *client) dev_err(client->dev, "failed to attach to domain: %d\n", err); - host1x_syncpt_free(client->syncpts[0]); - host1x_channel_put(gr3d->channel); iommu_group_put(gr3d->group); - return err; + goto free; } } } - return tegra_drm_register_client(dev->dev_private, drm); + err = tegra_drm_register_client(dev->dev_private, drm); + if (err < 0) { + dev_err(client->dev, "failed to register client: %d\n", err); + goto detach; + } + + return 0; + +detach: + if (gr3d->group) { + iommu_detach_group(tegra->domain, gr3d->group); + iommu_group_put(gr3d->group); + } +free: + host1x_syncpt_free(client->syncpts[0]); +put: + host1x_channel_put(gr3d->channel); + return err; } static int gr3d_exit(struct host1x_client *client) |