From e5f04703e96cadf28aa7935d49623f6e8ccf5a49 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 23 Jun 2006 02:05:09 -0700 Subject: [PATCH] --- yaml --- r: 29028 b: refs/heads/master c: 0d9a490abe1f69fda220f7866f6f23af41daa128 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/locks.c | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index 91200e533354..face490af5c2 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 090d2b185d8680fc26a2eaf4245d4171dcf4baf1 +refs/heads/master: 0d9a490abe1f69fda220f7866f6f23af41daa128 diff --git a/trunk/fs/locks.c b/trunk/fs/locks.c index 69435c68c1ed..c5ac6b40e766 100644 --- a/trunk/fs/locks.c +++ b/trunk/fs/locks.c @@ -834,14 +834,7 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request if (request->fl_flags & FL_ACCESS) goto out; - error = -ENOLCK; /* "no luck" */ - if (!(new_fl && new_fl2)) - goto out; - /* - * We've allocated the new locks in advance, so there are no - * errors possible (and no blocking operations) from here on. - * * Find the first old lock with the same owner as the new lock. */ @@ -938,10 +931,25 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request before = &fl->fl_next; } + /* + * The above code only modifies existing locks in case of + * merging or replacing. If new lock(s) need to be inserted + * all modifications are done bellow this, so it's safe yet to + * bail out. + */ + error = -ENOLCK; /* "no luck" */ + if (right && left == right && !new_fl2) + goto out; + error = 0; if (!added) { if (request->fl_type == F_UNLCK) goto out; + + if (!new_fl) { + error = -ENOLCK; + goto out; + } locks_copy_lock(new_fl, request); locks_insert_lock(before, new_fl); new_fl = NULL;