Skip to content

Commit

Permalink
drm/tegra: gr3d: Properly clean up resources
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
thierryreding committed May 17, 2018
1 parent dd99b4b commit 230630b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions drivers/gpu/drm/tegra/gr3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 230630b

Please sign in to comment.