Commit 26eedf6d authored by Andrey Grodzovsky's avatar Andrey Grodzovsky Committed by Alex Deucher
Browse files

drm/amdgpu: Fix extra call to amdgpu_ctx_put.



In amdgpu_cs_parser_init() in case of error handling
amdgpu_ctx_put() is called without setting p->ctx to NULL after that,
later amdgpu_cs_parser_fini() also calls amdgpu_ctx_put() again and
mess up the reference count.

Signed-off-by: default avatarAndrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 7d0a4282
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -97,7 +97,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
	if (copy_from_user(chunk_array, chunk_array_user,
	if (copy_from_user(chunk_array, chunk_array_user,
			   sizeof(uint64_t)*cs->in.num_chunks)) {
			   sizeof(uint64_t)*cs->in.num_chunks)) {
		ret = -EFAULT;
		ret = -EFAULT;
		goto put_ctx;
		goto free_chunk;
	}
	}


	p->nchunks = cs->in.num_chunks;
	p->nchunks = cs->in.num_chunks;
@@ -105,7 +105,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
			    GFP_KERNEL);
			    GFP_KERNEL);
	if (!p->chunks) {
	if (!p->chunks) {
		ret = -ENOMEM;
		ret = -ENOMEM;
		goto put_ctx;
		goto free_chunk;
	}
	}


	for (i = 0; i < p->nchunks; i++) {
	for (i = 0; i < p->nchunks; i++) {
@@ -191,8 +191,6 @@ free_partial_kdata:
	kfree(p->chunks);
	kfree(p->chunks);
	p->chunks = NULL;
	p->chunks = NULL;
	p->nchunks = 0;
	p->nchunks = 0;
put_ctx:
	amdgpu_ctx_put(p->ctx);
free_chunk:
free_chunk:
	kfree(chunk_array);
	kfree(chunk_array);