selftests: txring_overwrite: fix incorrect test of mmap() return value
authorFrank de Brabander <debrabander@gmail.com>
Fri, 5 Jul 2019 11:43:14 +0000 (13:43 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Jul 2019 22:39:38 +0000 (15:39 -0700)
If mmap() fails it returns MAP_FAILED, which is defined as ((void *) -1).
The current if-statement incorrectly tests if *ring is NULL.

Fixes: 358be656406d ("selftests/net: add txring_overwrite")
Signed-off-by: Frank de Brabander <debrabander@gmail.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/txring_overwrite.c

index fd8b1c663c391cafa42384034b1e0299e9dab2ec..7d9ea039450a377c7a7f964002dccd1ff7713767 100644 (file)
@@ -113,7 +113,7 @@ static int setup_tx(char **ring)
 
        *ring = mmap(0, req.tp_block_size * req.tp_block_nr,
                     PROT_READ | PROT_WRITE, MAP_SHARED, fdt, 0);
-       if (!*ring)
+       if (*ring == MAP_FAILED)
                error(1, errno, "mmap");
 
        return fdt;