diff options
-rw-r--r-- | fs/locks.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/fs/locks.c b/fs/locks.c index 69435c68c1ed..c5ac6b40e766 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -834,14 +834,7 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request | |||
834 | if (request->fl_flags & FL_ACCESS) | 834 | if (request->fl_flags & FL_ACCESS) |
835 | goto out; | 835 | goto out; |
836 | 836 | ||
837 | error = -ENOLCK; /* "no luck" */ | ||
838 | if (!(new_fl && new_fl2)) | ||
839 | goto out; | ||
840 | |||
841 | /* | 837 | /* |
842 | * We've allocated the new locks in advance, so there are no | ||
843 | * errors possible (and no blocking operations) from here on. | ||
844 | * | ||
845 | * Find the first old lock with the same owner as the new lock. | 838 | * Find the first old lock with the same owner as the new lock. |
846 | */ | 839 | */ |
847 | 840 | ||
@@ -938,10 +931,25 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request | |||
938 | before = &fl->fl_next; | 931 | before = &fl->fl_next; |
939 | } | 932 | } |
940 | 933 | ||
934 | /* | ||
935 | * The above code only modifies existing locks in case of | ||
936 | * merging or replacing. If new lock(s) need to be inserted | ||
937 | * all modifications are done bellow this, so it's safe yet to | ||
938 | * bail out. | ||
939 | */ | ||
940 | error = -ENOLCK; /* "no luck" */ | ||
941 | if (right && left == right && !new_fl2) | ||
942 | goto out; | ||
943 | |||
941 | error = 0; | 944 | error = 0; |
942 | if (!added) { | 945 | if (!added) { |
943 | if (request->fl_type == F_UNLCK) | 946 | if (request->fl_type == F_UNLCK) |
944 | goto out; | 947 | goto out; |
948 | |||
949 | if (!new_fl) { | ||
950 | error = -ENOLCK; | ||
951 | goto out; | ||
952 | } | ||
945 | locks_copy_lock(new_fl, request); | 953 | locks_copy_lock(new_fl, request); |
946 | locks_insert_lock(before, new_fl); | 954 | locks_insert_lock(before, new_fl); |
947 | new_fl = NULL; | 955 | new_fl = NULL; |