aboutsummaryrefslogtreecommitdiff
path: root/util/memfd.c
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2024-10-08 16:50:17 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2024-10-14 17:34:09 +0400
commitc90204b65400d77a918844889ad6789858406203 (patch)
tree11d87edd8a1e47eba728d3896a9f9df825cb9021 /util/memfd.c
parentdcf62fb6ce8f56709d74c9b79c15478b9f3ff266 (diff)
util/memfd: report potential errors on free
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>
Diffstat (limited to 'util/memfd.c')
-rw-r--r--util/memfd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/util/memfd.c b/util/memfd.c
index 4a3c07e0be..8a2e906962 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -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));
+ }
}
}