diff options
author | Christian König <christian.koenig@amd.com> | 2018-09-10 09:52:55 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-09-11 17:29:58 -0400 |
commit | 7893499e3022542f6522847837487019ea83f142 (patch) | |
tree | c8386e5b09fdbccbb2895a97c5a702bba58d8be5 | |
parent | 67f7cf9f76bccaadafc41b541e361ddb925c8921 (diff) |
drm/amdgpu: fix error handling in amdgpu_cs_user_fence_chunk
Slowly leaking memory one page at a time :)
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index 135d9d8c9506..c5cc648a1b4e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -40,6 +40,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
40 | { | 40 | { |
41 | struct drm_gem_object *gobj; | 41 | struct drm_gem_object *gobj; |
42 | unsigned long size; | 42 | unsigned long size; |
43 | int r; | ||
43 | 44 | ||
44 | gobj = drm_gem_object_lookup(p->filp, data->handle); | 45 | gobj = drm_gem_object_lookup(p->filp, data->handle); |
45 | if (gobj == NULL) | 46 | if (gobj == NULL) |
@@ -51,20 +52,26 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, | |||
51 | p->uf_entry.tv.shared = true; | 52 | p->uf_entry.tv.shared = true; |
52 | p->uf_entry.user_pages = NULL; | 53 | p->uf_entry.user_pages = NULL; |
53 | 54 | ||
54 | size = amdgpu_bo_size(p->uf_entry.robj); | ||
55 | if (size != PAGE_SIZE || (data->offset + 8) > size) | ||
56 | return -EINVAL; | ||
57 | |||
58 | *offset = data->offset; | ||
59 | |||
60 | drm_gem_object_put_unlocked(gobj); | 55 | drm_gem_object_put_unlocked(gobj); |
61 | 56 | ||
57 | size = amdgpu_bo_size(p->uf_entry.robj); | ||
58 | if (size != PAGE_SIZE || (data->offset + 8) > size) { | ||
59 | r = -EINVAL; | ||
60 | goto error_unref; | ||
61 | } | ||
62 | |||
62 | if (amdgpu_ttm_tt_get_usermm(p->uf_entry.robj->tbo.ttm)) { | 63 | if (amdgpu_ttm_tt_get_usermm(p->uf_entry.robj->tbo.ttm)) { |
63 | amdgpu_bo_unref(&p->uf_entry.robj); | 64 | r = -EINVAL; |
64 | return -EINVAL; | 65 | goto error_unref; |
65 | } | 66 | } |
66 | 67 | ||
68 | *offset = data->offset; | ||
69 | |||
67 | return 0; | 70 | return 0; |
71 | |||
72 | error_unref: | ||
73 | amdgpu_bo_unref(&p->uf_entry.robj); | ||
74 | return r; | ||
68 | } | 75 | } |
69 | 76 | ||
70 | static int amdgpu_cs_bo_handles_chunk(struct amdgpu_cs_parser *p, | 77 | static int amdgpu_cs_bo_handles_chunk(struct amdgpu_cs_parser *p, |