[libvirt PATCH 1/2] qemu: Don't check pidfile in qemuPasstStart

Jiri Denemark jdenemar at redhat.com
Wed Jan 11 09:44:58 UTC 2023


The pidfile is guaranteed to be non-NULL (thanks to glib allocation
functions) and it's dereferenced two lines above anyway.

Reported by coverity:

    /src/qemu/qemu_passt.c: 278 in qemuPasstStart()
    272         return 0;
    273
    274      error:
    275         ignore_value(virPidFileReadPathIfLocked(pidfile, &pid));
    276         if (pid != -1)
    277             virProcessKillPainfully(pid, true);
    >>>     CID 404360:  Null pointer dereferences  (REVERSE_INULL)
    >>>     Null-checking "pidfile" suggests that it may be null, but it
    >>>     has already been dereferenced on all paths leading to the check.
    278         if (pidfile)
    279             unlink(pidfile);
    280
    281         return -1;

Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/qemu/qemu_passt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
index 3355f7b2fa..5493eee494 100644
--- a/src/qemu/qemu_passt.c
+++ b/src/qemu/qemu_passt.c
@@ -275,8 +275,7 @@ qemuPasstStart(virDomainObj *vm,
     ignore_value(virPidFileReadPathIfLocked(pidfile, &pid));
     if (pid != -1)
         virProcessKillPainfully(pid, true);
-    if (pidfile)
-        unlink(pidfile);
+    unlink(pidfile);
 
     return -1;
 }
-- 
2.39.0



More information about the libvir-list mailing list