mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-26 21:55:44 +07:00
pam: do not leak file descriptor if flock fails
If flock fails, fd is not returned to caller so it cannot clean up.
This commit is contained in:
parent
756a8d17bb
commit
90102b22ba
@ -198,8 +198,12 @@ static int open_file_and_lock(const char *fn) {
|
||||
* as the filesystems in question should be local, and only
|
||||
* locally accessible, and most likely even tmpfs. */
|
||||
|
||||
if (flock(fd, LOCK_EX) < 0)
|
||||
return -errno;
|
||||
if (flock(fd, LOCK_EX) < 0) {
|
||||
int r = -errno;
|
||||
|
||||
close_nointr_nofail(fd);
|
||||
return r;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user