]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Remove surplus check and fix leak
authorMarc Rittinghaus <marc.rittinghaus@unikraft.io>
Mon, 24 Apr 2023 14:57:21 +0000 (16:57 +0200)
committerUnikraft <monkey@unikraft.io>
Tue, 2 May 2023 20:19:25 +0000 (20:19 +0000)
The dedicated check for a readonly filesystem can be removed
in sys_utimensat(), because it is part of vn_access(). The commit
also fixes a leak of reference to the dentry in case of an error.

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 830b76e0c749f12ad885077f547df1a06089ae3c..d85c08f55b2f02a8e9685f12971306abb75a9984 100644 (file)
@@ -1471,14 +1471,11 @@ sys_utimensat(int dirfd, const char *pathname, const struct timespec times[2], i
                UK_ASSERT(dp);
        }
 
-       if (dp->d_mount->m_flags & MNT_RDONLY) {
-               error = EROFS;
-       } else {
-               if (vn_access(dp->d_vnode, VWRITE)) {
-                       return EACCES;
-               }
-               error = vn_settimes(dp->d_vnode, timespec_times);
-       }
+       error = vn_access(dp->d_vnode, VWRITE);
+       if (unlikely(error))
+               goto exit_rel;
+
+       error = vn_settimes(dp->d_vnode, timespec_times);
 
 exit_rel:
        if (fp)