lkml.org 
[lkml]   [2021]   [Jul]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drm/i915: Fix error return code in igt_vma_create()
Date
Although 'err' has been initialized to -ENOMEM, but it will be reassigned
by the "err = create_vmas(...)" statement in the for loop. So that, the
value of 'err' may be zero when i915_gem_object_create_internal() or
mock_context() failed.

Fix to reassign 'err' before 'goto out'.

Fixes: e3c7a1c5377e ("drm/i915: Test creation of VMA")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/gpu/drm/i915/selftests/i915_vma.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c
index dd0607254a95..96771c341f29 100644
--- a/drivers/gpu/drm/i915/selftests/i915_vma.c
+++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
@@ -156,7 +156,7 @@ static int igt_vma_create(void *arg)
IGT_TIMEOUT(end_time);
LIST_HEAD(contexts);
LIST_HEAD(objects);
- int err = -ENOMEM;
+ int err;

/* Exercise creating many vma amonst many objections, checking the
* vma creation and lookup routines.
@@ -166,8 +166,10 @@ static int igt_vma_create(void *arg)
for_each_prime_number(num_obj, ULONG_MAX - 1) {
for (; no < num_obj; no++) {
obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
- if (IS_ERR(obj))
+ if (IS_ERR(obj)) {
+ err = PTR_ERR(obj);
goto out;
+ }

list_add(&obj->st_link, &objects);
}
@@ -176,8 +178,10 @@ static int igt_vma_create(void *arg)
for_each_prime_number(num_ctx, 2 * BITS_PER_LONG) {
for (; nc < num_ctx; nc++) {
ctx = mock_context(i915, "mock");
- if (!ctx)
+ if (!ctx) {
+ err = -ENOMEM;
goto out;
+ }

list_move(&ctx->link, &contexts);
}
--
2.25.1
\
 
 \ /
  Last update: 2021-07-16 03:13    [W:0.027 / U:0.300 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site