Skip to content

Commit 2555349

Browse files
Cong Liurodrigovivi
authored andcommitted
drm/i915: Fix memory leaks in function live_nop_switch
Be sure to properly free the allocated memory before exiting the live_nop_switch function. Signed-off-by: Cong Liu <liucong2@kylinos.cn> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230517050204.4111874-1-liucong2@kylinos.cn
1 parent 1a365a2 commit 2555349

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int live_nop_switch(void *arg)
6666
ctx[n] = live_context(i915, file);
6767
if (IS_ERR(ctx[n])) {
6868
err = PTR_ERR(ctx[n]);
69-
goto out_file;
69+
goto out_ctx;
7070
}
7171
}
7272

@@ -82,7 +82,7 @@ static int live_nop_switch(void *arg)
8282
this = igt_request_alloc(ctx[n], engine);
8383
if (IS_ERR(this)) {
8484
err = PTR_ERR(this);
85-
goto out_file;
85+
goto out_ctx;
8686
}
8787
if (rq) {
8888
i915_request_await_dma_fence(this, &rq->fence);
@@ -96,7 +96,7 @@ static int live_nop_switch(void *arg)
9696
intel_gt_set_wedged(engine->gt);
9797
i915_request_put(rq);
9898
err = -EIO;
99-
goto out_file;
99+
goto out_ctx;
100100
}
101101
i915_request_put(rq);
102102

@@ -107,7 +107,7 @@ static int live_nop_switch(void *arg)
107107

108108
err = igt_live_test_begin(&t, i915, __func__, engine->name);
109109
if (err)
110-
goto out_file;
110+
goto out_ctx;
111111

112112
end_time = jiffies + i915_selftest.timeout_jiffies;
113113
for_each_prime_number_from(prime, 2, 8192) {
@@ -120,7 +120,7 @@ static int live_nop_switch(void *arg)
120120
this = igt_request_alloc(ctx[n % nctx], engine);
121121
if (IS_ERR(this)) {
122122
err = PTR_ERR(this);
123-
goto out_file;
123+
goto out_ctx;
124124
}
125125

126126
if (rq) { /* Force submission order */
@@ -165,14 +165,16 @@ static int live_nop_switch(void *arg)
165165

166166
err = igt_live_test_end(&t);
167167
if (err)
168-
goto out_file;
168+
goto out_ctx;
169169

170170
pr_info("Switch latencies on %s: 1 = %lluns, %lu = %lluns\n",
171171
engine->name,
172172
ktime_to_ns(times[0]),
173173
prime - 1, div64_u64(ktime_to_ns(times[1]), prime - 1));
174174
}
175175

176+
out_ctx:
177+
kfree(ctx);
176178
out_file:
177179
fput(file);
178180
return err;

0 commit comments

Comments
 (0)