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

Chris Wilson chris at chris-wilson.co.uk
Tue Apr 14 09:28:22 UTC 2020


Quoting Ruhl, Michael J (2020-04-13 19:27:42)
> >-----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;

I had to double check that in a function called leak() we weren't
actually waiting for the failure. But no, this function allocates and
makes sure that it is populated and faulted, then leaks it.

Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris


More information about the igt-dev mailing list