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@xxxxxxxxxx> Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx> --- 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 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx