]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Fix leak in sys_futimens
authorMarc Rittinghaus <marc.rittinghaus@unikraft.io>
Mon, 24 Apr 2023 15:21:15 +0000 (17:21 +0200)
committerUnikraft <monkey@unikraft.io>
Tue, 2 May 2023 20:19:25 +0000 (20:19 +0000)
Previously, sys_futimens() retrieved a reference to the file
descriptor to get a value for the pathname argument. The reference
was not freed afterwards. Since sys_utimensat() has been changed
to accept NULL as pathname and work on dirfd instead, the code
can be removed altogether.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865

lib/vfscore/syscalls.c

index a7a42292793fc244dc68d439aa03144f25c5f16a..45acb841ec7b04cc41fcb67c5339a013f02f93ac 100644 (file)
@@ -1502,20 +1502,7 @@ exit_rel:
 int
 sys_futimens(int fd, const struct timespec times[2])
 {
-       int error;
-       struct vfscore_file *fp;
-       char *pathname;
-
-       fp = vfscore_get_file(fd);
-       if (!fp)
-               return EBADF;
-
-       if (!fp->f_dentry)
-               return EBADF;
-
-       pathname = fp->f_dentry->d_path;
-       error = sys_utimensat(AT_FDCWD, pathname, times, 0);
-       return error;
+       return sys_utimensat(fd, NULL, times, 0);
 }
 
 int