Blame 0205-compatfd.c-Don-t-pass-NULL-pointer-to-SYS_signalfd.patch

cd9d16
From 89409a7eee1d25a91c31402fdb35d8554e3a99d0 Mon Sep 17 00:00:00 2001
cd9d16
From: Peter Maydell <peter.maydell@linaro.org>
cd9d16
Date: Thu, 13 Oct 2011 18:45:37 +0100
cd9d16
Subject: [PATCH] compatfd.c: Don't pass NULL pointer to SYS_signalfd
cd9d16
MIME-Version: 1.0
cd9d16
Content-Type: text/plain; charset=UTF-8
cd9d16
Content-Transfer-Encoding: 8bit
cd9d16
cd9d16
Don't pass a NULL pointer in to SYS_signalfd in qemu_signalfd_available():
cd9d16
this isn't valid and Valgrind complains about it.
cd9d16
cd9d16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
cd9d16
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
cd9d16
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
cd9d16
(cherry picked from commit 7f84c1272b601be88daeb828ec1890890c7aae25)
cd9d16
cd9d16
Signed-off-by: Bruce Rogers <brogers@suse.com>
cd9d16
Signed-off-by: Andreas Färber <afaerber@suse.de>
cd9d16
---
cd9d16
 compatfd.c | 12 ++++++++++--
cd9d16
 1 file changed, 10 insertions(+), 2 deletions(-)
cd9d16
cd9d16
diff --git a/compatfd.c b/compatfd.c
cd9d16
index 31654c6..02306a4 100644
cd9d16
--- a/compatfd.c
cd9d16
+++ b/compatfd.c
cd9d16
@@ -119,9 +119,17 @@ int qemu_signalfd(const sigset_t *mask)
cd9d16
 bool qemu_signalfd_available(void)
cd9d16
 {
cd9d16
 #ifdef CONFIG_SIGNALFD
cd9d16
+    sigset_t mask;
cd9d16
+    int fd;
cd9d16
+    bool ok;
cd9d16
+    sigemptyset(&mask);
cd9d16
     errno = 0;
cd9d16
-    syscall(SYS_signalfd, -1, NULL, _NSIG / 8);
cd9d16
-    return errno != ENOSYS;
cd9d16
+    fd = syscall(SYS_signalfd, -1, &mask, _NSIG / 8);
cd9d16
+    ok = (errno != ENOSYS);
cd9d16
+    if (fd >= 0) {
cd9d16
+        close(fd);
cd9d16
+    }
cd9d16
+    return ok;
cd9d16
 #else
cd9d16
     return false;
cd9d16
 #endif
cd9d16
-- 
cd9d16
1.7.11.2
cd9d16