mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-24 12:22:20 +00:00
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> (cherry picked from commit 3f43bb832646588f57303f09fe5c7ac8ba7602d8)
This commit is contained in:
parent
dbc11c4f97
commit
d2cebf0b05
@ -592,9 +592,8 @@ virPidFileForceCleanupPath(const char *path)
|
|||||||
if (virPidFileReadPath(path, &pid) < 0)
|
if (virPidFileReadPath(path, &pid) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virPidFileAcquirePath(path, false, 0) == 0) {
|
fd = virPidFileAcquirePath(path, false, 0);
|
||||||
virPidFileReleasePath(path, fd);
|
if (fd < 0) {
|
||||||
} else {
|
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
|
|
||||||
/* Only kill the process if the pid is valid one. 0 means
|
/* Only kill the process if the pid is valid one. 0 means
|
||||||
@ -607,5 +606,8 @@ virPidFileForceCleanupPath(const char *path)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd)
|
||||||
|
virPidFileReleasePath(path, fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user