diff mbox series

[02/17] Fix load_image error check for mmap

Message ID 20240511115400.7587-3-richard.henderson@linaro.org
State New
Headers show
Series RISU misc updates | expand

Commit Message

Richard Henderson May 11, 2024, 11:53 a.m. UTC
mmap does not return null on failure, but MAP_FAILED.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 risu.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Philippe Mathieu-Daudé May 15, 2024, 12:51 p.m. UTC | #1
On 11/5/24 13:53, Richard Henderson wrote:
> mmap does not return null on failure, but MAP_FAILED.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   risu.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff mbox series

Patch

diff --git a/risu.c b/risu.c
index 36fc82a..6b6295c 100644
--- a/risu.c
+++ b/risu.c
@@ -362,10 +362,9 @@  static void load_image(const char *imgfile)
     /* Map writable because we include the memory area for store
      * testing in the image.
      */
-    addr =
-        mmap(0, len, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd,
-             0);
-    if (!addr) {
+    addr = mmap(0, len, PROT_READ | PROT_WRITE | PROT_EXEC,
+                MAP_PRIVATE, fd, 0);
+    if (addr == MAP_FAILED) {
         perror("mmap");
         exit(EXIT_FAILURE);
     }