selftests/core: add regression test for CLOSE_RANGE_UNSHARE | CLOSE_RANGE_CLOEXEC
[linux-2.6-microblaze.git] / fs / locks.c
index ed95cd8..99ca97e 100644 (file)
@@ -2539,14 +2539,15 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
         */
        if (!error && file_lock->fl_type != F_UNLCK &&
            !(file_lock->fl_flags & FL_OFDLCK)) {
+               struct files_struct *files = current->files;
                /*
                 * We need that spin_lock here - it prevents reordering between
                 * update of i_flctx->flc_posix and check for it done in
                 * close(). rcu_read_lock() wouldn't do.
                 */
-               spin_lock(&current->files->file_lock);
-               f = fcheck(fd);
-               spin_unlock(&current->files->file_lock);
+               spin_lock(&files->file_lock);
+               f = files_lookup_fd_locked(files, fd);
+               spin_unlock(&files->file_lock);
                if (f != filp) {
                        file_lock->fl_type = F_UNLCK;
                        error = do_lock_file_wait(filp, cmd, file_lock);
@@ -2670,14 +2671,15 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
         */
        if (!error && file_lock->fl_type != F_UNLCK &&
            !(file_lock->fl_flags & FL_OFDLCK)) {
+               struct files_struct *files = current->files;
                /*
                 * We need that spin_lock here - it prevents reordering between
                 * update of i_flctx->flc_posix and check for it done in
                 * close(). rcu_read_lock() wouldn't do.
                 */
-               spin_lock(&current->files->file_lock);
-               f = fcheck(fd);
-               spin_unlock(&current->files->file_lock);
+               spin_lock(&files->file_lock);
+               f = files_lookup_fd_locked(files, fd);
+               spin_unlock(&files->file_lock);
                if (f != filp) {
                        file_lock->fl_type = F_UNLCK;
                        error = do_lock_file_wait(filp, cmd, file_lock);