selftests/core: add regression test for CLOSE_RANGE_UNSHARE | CLOSE_RANGE_CLOEXEC
[linux-2.6-microblaze.git] / fs / locks.c
index 1f84a03..99ca97e 100644 (file)
@@ -542,7 +542,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
        if (l->l_len > 0) {
                if (l->l_len - 1 > OFFSET_MAX - fl->fl_start)
                        return -EOVERFLOW;
-               fl->fl_end = fl->fl_start + l->l_len - 1;
+               fl->fl_end = fl->fl_start + (l->l_len - 1);
 
        } else if (l->l_len < 0) {
                if (fl->fl_start + l->l_len < 0)
@@ -750,7 +750,7 @@ static void __locks_wake_up_blocks(struct file_lock *blocker)
 }
 
 /**
- *     locks_delete_lock - stop waiting for a file lock
+ *     locks_delete_block - stop waiting for a file lock
  *     @waiter: the lock which was waiting
  *
  *     lockd/nfsd need to disconnect the lock while working on it.
@@ -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);