]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: gpu: Sanitize error values in qemuVhostUserGPUGetPid
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Nov 2019 12:17:11 +0000 (13:17 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 14 Nov 2019 11:42:09 +0000 (12:42 +0100)
The caller doesn't care about the actual return value, so return -1
rather than errno.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_vhost_user_gpu.c

index 37e424eac33803cac6b2636d2306ef30085a358f..51244f9b35c0b08dd9baa989d3d3aa17f4f0d26e 100644 (file)
@@ -61,7 +61,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
  * @alias: video device alias
  * @pid: pointer to pid
  *
- * Return -errno upon error, or zero on successful reading of the pidfile.
+ * Return -1 upon error, or zero on successful reading of the pidfile.
  * If the PID was not still alive, zero will be returned, and @pid will be
  * set to -1;
  */
@@ -74,11 +74,13 @@ qemuVhostUserGPUGetPid(const char *binPath,
 {
     g_autofree char *pidfile = NULL;
 
-    pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias);
-    if (!pidfile)
-        return -ENOMEM;
+    if (!(pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias)))
+        return -1;
+
+    if (virPidFileReadPathIfAlive(pidfile, pid, binPath) < 0)
+        return -1;
 
-    return virPidFileReadPathIfAlive(pidfile, pid, binPath);
+    return 0;
 }