From 12d194404ca00e57d790b0d37a8517b5f50ec8df Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 11 Jan 2023 09:54:59 +0100 Subject: [PATCH] qemu: Don't check pidfile in qemuPasstStart 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 Reviewed-by: Erik Skultety --- 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; }