util: fix releasing pidfile in cleanup

Coverity found out the very obvious problem in the code.  That is that
virPidFileReleasePath() was called only if
virPidFileAcquirePath() returned 0.  But virPidFileAcquirePath() doesn't
return only 0 on success, but the FD that needs to be closed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander committed 2014-11-04 12:06:38 +01:00
1 parent c3012a023f
commit 3f43bb8326
1 file changed
+5 -3
+5 -3
View File
@@ -592,9 +592,8 @@ virPidFileForceCleanupPath(const char *path)
if (virPidFileReadPath(path, &pid) < 0)
return -1;
if (virPidFileAcquirePath(path, false, 0) == 0) {
virPidFileReleasePath(path, fd);
} else {
fd = virPidFileAcquirePath(path, false, 0);
if (fd < 0) {
virResetLastError();
/* Only kill the process if the pid is valid one. 0 means
@@ -607,5 +606,8 @@ virPidFileForceCleanupPath(const char *path)
return -1;
}
if (fd)
virPidFileReleasePath(path, fd);
return 0;
}