Skip to content

Commit 317be9c

Browse files
KKaras169169Andi Shyti
authored andcommitted
drm/i915/gt: Protect against overflow in active_engine()
It is unlikely, but possible for the first call to intel_context_create() to fail with -ENOMEM, which would result in entering the following code block and decrementing "count", when it is set to 0 (initial condition in the for loop). Protect from overflowing the variable by checking for 0 value of "count" before entering the loop. Signed-off-by: Krzysztof Karas <[email protected]> Reviewed-by: Sebastian Brzezinka <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/pogr74jktdqehrfap4tjky23ees4x7erh5dwgg5jb2n522cfkw@kpnxe4qzx4pj
1 parent f768ebb commit 317be9c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/gpu/drm/i915/gt/selftest_hangcheck.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ static void active_engine(struct kthread_work *work)
904904
arg->result = PTR_ERR(ce[count]);
905905
pr_err("[%s] Create context #%ld failed: %d!\n",
906906
engine->name, count, arg->result);
907+
if (!count)
908+
return;
907909
while (--count)
908910
intel_context_put(ce[count]);
909911
return;

0 commit comments

Comments
 (0)