Unverified Commit 7b55c48f authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10733 filelock: Remove locks reliably when fcntl/close race is detected

parents a421e238 fed067a4
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -2530,8 +2530,9 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
	error = do_lock_file_wait(filp, cmd, file_lock);

	/*
	 * Attempt to detect a close/fcntl race and recover by releasing the
	 * lock that was just acquired. There is no need to do that when we're
	 * Detect close/fcntl races and recover by zapping all POSIX locks
	 * associated with this file and our files_struct, just like on
	 * filp_flush(). There is no need to do that when we're
	 * unlocking though, or for OFD locks.
	 */
	if (!error && file_lock->fl_type != F_UNLCK &&
@@ -2545,9 +2546,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
		f = fcheck(fd);
		spin_unlock(&current->files->file_lock);
		if (f != filp) {
			file_lock->fl_type = F_UNLCK;
			error = do_lock_file_wait(filp, cmd, file_lock);
			WARN_ON_ONCE(error);
			locks_remove_posix(filp, current->files);
			error = -EBADF;
		}
	}