[igt-dev] [PATCH i-g-t] igt/gem_shrink: Fix reversed logic when mmap fails

Ruhl, Michael J michael.j.ruhl at intel.com
Mon Apr 13 18:27:42 UTC 2020


>-----Original Message-----
>From: Dixit, Ashutosh <ashutosh.dixit at intel.com>
>Sent: Monday, April 13, 2020 2:25 PM
>To: igt-dev at lists.freedesktop.org
>Cc: Chris Wilson <chris at chris-wilson.co.uk>; Ruhl, Michael J
><michael.j.ruhl at intel.com>
>Subject: [PATCH i-g-t] igt/gem_shrink: Fix reversed logic when mmap fails
>
>Can't touch the memory if mmap returns MAP_FAILED.
>
>v2: s/(char *)-1)/MAP_FAILED/ (Mike Ruhl)

😊

Reviewed-by: Michael J. Ruhl <michael.j.ruhl at intel.com>

>Fixes: 9cff3be127("igt/gem_shrink: Reduce oom spam")
>Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
>---
> tests/i915/gem_shrink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tests/i915/gem_shrink.c b/tests/i915/gem_shrink.c
>index 11aa9efc1..e434613eb 100644
>--- a/tests/i915/gem_shrink.c
>+++ b/tests/i915/gem_shrink.c
>@@ -274,7 +274,7 @@ static void leak(int fd, uint64_t alloc)
> 	ptr = mmap(NULL, alloc, PROT_READ | PROT_WRITE,
> 		   MAP_ANON | MAP_PRIVATE | MAP_POPULATE,
> 		   -1, 0);
>-	if (ptr != (char *)-1)
>+	if (ptr == MAP_FAILED)
> 		return;
>
> 	while (alloc) {
>--
>2.26.0



More information about the igt-dev mailing list