os-posix: Plug fd leak in qemu_create_pidfile()
Spotted by Coverity. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
095ed5be7b
commit
1bbd1592c8
@ -372,13 +372,16 @@ int qemu_create_pidfile(const char *filename)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (lockf(fd, F_TLOCK, 0) == -1) {
|
if (lockf(fd, F_TLOCK, 0) == -1) {
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());
|
len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());
|
||||||
if (write(fd, buffer, len) != len) {
|
if (write(fd, buffer, len) != len) {
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user