[PATCH] drm/amdgpu: use failed label to handle context init failure

Alex Deucher alexdeucher at gmail.com
Wed Oct 26 15:12:19 UTC 2016


On Wed, Oct 26, 2016 at 5:11 AM, Huang Rui <ray.huang at amd.com> wrote:
> Signed-off-by: Huang Rui <ray.huang at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 6d90d7b..d7df6e0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -56,18 +56,18 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)
>                 r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity,
>                                           rq, amdgpu_sched_jobs);
>                 if (r)
> -                       break;
> +                       goto failed;
>         }
>
> -       if (i < adev->num_rings) {
> -               for (j = 0; j < i; j++)
> -                       amd_sched_entity_fini(&adev->rings[j]->sched,
> -                                             &ctx->rings[j].entity);
> -               kfree(ctx->fences);
> -               ctx->fences = NULL;
> -               return r;
> -       }
>         return 0;
> +
> +failed:
> +       for (j = 0; j < i; j++)
> +               amd_sched_entity_fini(&adev->rings[j]->sched,
> +                                     &ctx->rings[j].entity);
> +       kfree(ctx->fences);
> +       ctx->fences = NULL;
> +       return r;
>  }
>
>  static void amdgpu_ctx_fini(struct amdgpu_ctx *ctx)
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list