public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/tegra: gr2d: Properly clean up resources
Date: Fri, 4 May 2018 17:16:35 +0300	[thread overview]
Message-ID: <5f388649-47cb-d332-5434-75bbb732e268@gmail.com> (raw)
In-Reply-To: <20180504133707.22451-2-thierry.reding@gmail.com>

On 04.05.2018 16:37, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/gpu/drm/tegra/gr2d.c | 28 ++++++++++++++++++++++------
>  1 file changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/gr2d.c b/drivers/gpu/drm/tegra/gr2d.c
> index 8eb530a85dd0..0b42e99da8ad 100644
> --- a/drivers/gpu/drm/tegra/gr2d.c
> +++ b/drivers/gpu/drm/tegra/gr2d.c
> @@ -42,8 +42,9 @@ static int gr2d_init(struct host1x_client *client)
>  
>  	client->syncpts[0] = host1x_syncpt_request(client, flags);
>  	if (!client->syncpts[0]) {
> -		host1x_channel_put(gr2d->channel);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		dev_err(client->dev, "failed to request syncpoint: %d\n", err);
> +		goto put;
>  	}
>  
>  	if (tegra->domain) {
> @@ -55,15 +56,30 @@ static int gr2d_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(gr2d->channel);
>  				iommu_group_put(gr2d->group);
> -				return err;
> +				goto free;
>  			}
>  		}
>  	}
>  
> -	return tegra_drm_register_client(tegra, drm);
> +	err = tegra_drm_register_client(tegra, drm);
> +	if (err < 0) {
> +		dev_err(client->dev, "failed to register client: %d\n", err);
> +		goto detach;
> +	}
> +
> +	return 0;
> +
> +detach:
> +	if (gr2d->group) {
> +		iommu_detach_group(tegra->domain, gr2d->group);
> +		iommu_group_put(gr2d->group);
> +	}
> +free:
> +	host1x_syncpt_free(client->syncpts[0]);
> +put:
> +	host1x_channel_put(gr2d->channel);
> +	return err;
>  }
>  
>  static int gr2d_exit(struct host1x_client *client)
> 

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-05-04 14:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04 13:37 [PATCH 1/4] drm/tegra: dc: Free syncpoint on errors Thierry Reding
2018-05-04 13:37 ` [PATCH 2/4] drm/tegra: gr2d: Properly clean up resources Thierry Reding
2018-05-04 14:16   ` Dmitry Osipenko [this message]
2018-05-07 20:57   ` Dmitry Osipenko
2018-05-04 13:37 ` [PATCH 3/4] drm/tegra: gr3d: " Thierry Reding
2018-05-04 14:16   ` Dmitry Osipenko
2018-05-04 13:37 ` [PATCH 4/4] drm/tegra: Refactor IOMMU attach/detach Thierry Reding
2018-05-04 14:23   ` Dmitry Osipenko
2018-05-04 15:10     ` Thierry Reding
2018-05-04 15:17       ` Dmitry Osipenko
2018-05-04 15:25         ` Thierry Reding
2018-05-10 23:42   ` Dmitry Osipenko
2018-05-04 14:14 ` [PATCH 1/4] drm/tegra: dc: Free syncpoint on errors Dmitry Osipenko
2018-05-04 15:16 ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f388649-47cb-d332-5434-75bbb732e268@gmail.com \
    --to=digetx@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox