]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
util/memfd: report potential errors on free
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 8 Oct 2024 12:50:17 +0000 (16:50 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 14 Oct 2024 13:34:09 +0000 (17:34 +0400)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-ID: <20241008125028.1177932-9-marcandre.lureau@redhat.com>

util/memfd.c

index 4a3c07e0bee6ddcf168553f9c96005bdb11e42c5..8a2e9069627c2c3f5fc4de77d231311e8dad4e8e 100644 (file)
@@ -28,6 +28,7 @@
 #include "qemu/osdep.h"
 
 #include "qapi/error.h"
+#include "qemu/error-report.h"
 #include "qemu/memfd.h"
 #include "qemu/host-utils.h"
 
@@ -149,11 +150,15 @@ err:
 void qemu_memfd_free(void *ptr, size_t size, int fd)
 {
     if (ptr) {
-        munmap(ptr, size);
+        if (munmap(ptr, size) != 0) {
+            error_report("memfd munmap() failed: %s", strerror(errno));
+        }
     }
 
     if (fd != -1) {
-        close(fd);
+        if (close(fd) != 0) {
+            error_report("memfd close() failed: %s", strerror(errno));
+        }
     }
 }