From: Olaf Kirch <okir@suse.de>
[deliverable/linux.git] / fs / locks.c
index f7daa5f48949c41ea02b687e1521a440387b0592..7eb1d77b9204deccce359d4b2f9f1e9ffcb954ab 100644 (file)
@@ -829,12 +829,16 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request)
                /* Detect adjacent or overlapping regions (if same lock type)
                 */
                if (request->fl_type == fl->fl_type) {
+                       /* In all comparisons of start vs end, use
+                        * "start - 1" rather than "end + 1". If end
+                        * is OFFSET_MAX, end + 1 will become negative.
+                        */
                        if (fl->fl_end < request->fl_start - 1)
                                goto next_lock;
                        /* If the next lock in the list has entirely bigger
                         * addresses than the new one, insert the lock here.
                         */
-                       if (fl->fl_start > request->fl_end + 1)
+                       if (fl->fl_start - 1 > request->fl_end)
                                break;
 
                        /* If we come here, the new and old lock are of the
This page took 0.028262 seconds and 5 git commands to generate.