2021-03-08 09:02:44

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] gpu: drm: i915: fix error return code of igt_buddy_alloc_smoke()

When i915_random_order() returns NULL to order, no error return code of
igt_buddy_alloc_smoke() is assigned.
To fix this bug, err is assigned with -EINVAL in this case.

Fixes: 1fe3818d17c9 ("drm/i915/selftests: try to rein in alloc_smoke")
Reported-by: TOTE Robot <[email protected]>
Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/gpu/drm/i915/selftests/i915_buddy.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/selftests/i915_buddy.c b/drivers/gpu/drm/i915/selftests/i915_buddy.c
index 632b912b0bc9..cf9b551b77e1 100644
--- a/drivers/gpu/drm/i915/selftests/i915_buddy.c
+++ b/drivers/gpu/drm/i915/selftests/i915_buddy.c
@@ -318,8 +318,10 @@ static int igt_buddy_alloc_smoke(void *arg)
}

order = i915_random_order(mm.max_order + 1, &prng);
- if (!order)
+ if (!order) {
+ err = -EINVAL;
goto out_fini;
+ }

for (i = 0; i <= mm.max_order; ++i) {
struct i915_buddy_block *block;
--
2.17.1


2021-03-08 09:20:32

by Chris Wilson

[permalink] [raw]
Subject: Re: [PATCH] gpu: drm: i915: fix error return code of igt_buddy_alloc_smoke()

Quoting Jia-Ju Bai (2021-03-08 08:59:52)
> When i915_random_order() returns NULL to order, no error return code of
> igt_buddy_alloc_smoke() is assigned.
> To fix this bug, err is assigned with -EINVAL in this case.

It would not be EINVAL since that is used for a reference failure, but
in this case the idea was to return 0 as no testing was done and the
ENOMEM was raised before testing began i.e. not an internal and
unexpected driver allocation failure.
-Chris

2021-03-08 09:30:30

by Jia-Ju Bai

[permalink] [raw]
Subject: Re: [PATCH] gpu: drm: i915: fix error return code of igt_buddy_alloc_smoke()



On 2021/3/8 17:18, Chris Wilson wrote:
> Quoting Jia-Ju Bai (2021-03-08 08:59:52)
>> When i915_random_order() returns NULL to order, no error return code of
>> igt_buddy_alloc_smoke() is assigned.
>> To fix this bug, err is assigned with -EINVAL in this case.
> It would not be EINVAL since that is used for a reference failure, but
> in this case the idea was to return 0 as no testing was done and the
> ENOMEM was raised before testing began i.e. not an internal and
> unexpected driver allocation failure.
> -Chris

Okay, thanks for your reply :)


Best wishes,
Jia-Ju Bai