hdparm/0001-hdparm-fallocate-close-fd.patch
Zhiqiang Liu 97f1f71440 hdparm: rename patches and fix one fd leak in sysfs_write_attr()
rename patches and fix one fd leak in sysfs_write_attr().

Fix issue: https://gitee.com/src-openeuler/hdparm/issues/I4S2C0

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
(cherry picked from commit 8f2ce8643ae9257830d4e27cedd46bca27aafd50)
2022-03-01 19:20:54 +08:00

17 lines
375 B
Diff

diff --git a/fallocate.c b/fallocate.c
index 4e60459..d73c0f9 100644
--- a/fallocate.c
+++ b/fallocate.c
@@ -39,9 +39,11 @@ int do_fallocate_syscall (const char *path, __u64 bytecount)
err = syscall(SYS_fallocate, fd, mode, offset, len);
if (err >= 0) {
fsync(fd);
+ close(fd);
exit(0);
}
err = errno;
+ close(fd);
unlink(path);
}
perror(path);