diff options
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/locks.c b/fs/locks.c index f7daa5f48949..7eb1d77b9204 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -829,12 +829,16 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request) | |||
829 | /* Detect adjacent or overlapping regions (if same lock type) | 829 | /* Detect adjacent or overlapping regions (if same lock type) |
830 | */ | 830 | */ |
831 | if (request->fl_type == fl->fl_type) { | 831 | if (request->fl_type == fl->fl_type) { |
832 | /* In all comparisons of start vs end, use | ||
833 | * "start - 1" rather than "end + 1". If end | ||
834 | * is OFFSET_MAX, end + 1 will become negative. | ||
835 | */ | ||
832 | if (fl->fl_end < request->fl_start - 1) | 836 | if (fl->fl_end < request->fl_start - 1) |
833 | goto next_lock; | 837 | goto next_lock; |
834 | /* If the next lock in the list has entirely bigger | 838 | /* If the next lock in the list has entirely bigger |
835 | * addresses than the new one, insert the lock here. | 839 | * addresses than the new one, insert the lock here. |
836 | */ | 840 | */ |
837 | if (fl->fl_start > request->fl_end + 1) | 841 | if (fl->fl_start - 1 > request->fl_end) |
838 | break; | 842 | break; |
839 | 843 | ||
840 | /* If we come here, the new and old lock are of the | 844 | /* If we come here, the new and old lock are of the |