lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 16 Jul 2021 09:11:12 +0800
From:   Zhen Lei <thunder.leizhen@...wei.com>
To:     Jani Nikula <jani.nikula@...ux.intel.com>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        intel-gfx <intel-gfx@...ts.freedesktop.org>,
        dri-devel <dri-devel@...ts.freedesktop.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
CC:     Zhen Lei <thunder.leizhen@...wei.com>
Subject: [PATCH] drm/i915: Fix error return code in igt_vma_create()

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@...wei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@...wei.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ