diff options
-rw-r--r-- | fs/locks.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/locks.c b/fs/locks.c index c5ac6b40e766..2344f241c687 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -794,7 +794,8 @@ out: | |||
794 | static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request, struct file_lock *conflock) | 794 | static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request, struct file_lock *conflock) |
795 | { | 795 | { |
796 | struct file_lock *fl; | 796 | struct file_lock *fl; |
797 | struct file_lock *new_fl, *new_fl2; | 797 | struct file_lock *new_fl = NULL; |
798 | struct file_lock *new_fl2 = NULL; | ||
798 | struct file_lock *left = NULL; | 799 | struct file_lock *left = NULL; |
799 | struct file_lock *right = NULL; | 800 | struct file_lock *right = NULL; |
800 | struct file_lock **before; | 801 | struct file_lock **before; |
@@ -803,9 +804,15 @@ static int __posix_lock_file_conf(struct inode *inode, struct file_lock *request | |||
803 | /* | 804 | /* |
804 | * We may need two file_lock structures for this operation, | 805 | * We may need two file_lock structures for this operation, |
805 | * so we get them in advance to avoid races. | 806 | * so we get them in advance to avoid races. |
807 | * | ||
808 | * In some cases we can be sure, that no new locks will be needed | ||
806 | */ | 809 | */ |
807 | new_fl = locks_alloc_lock(); | 810 | if (!(request->fl_flags & FL_ACCESS) && |
808 | new_fl2 = locks_alloc_lock(); | 811 | (request->fl_type != F_UNLCK || |
812 | request->fl_start != 0 || request->fl_end != OFFSET_MAX)) { | ||
813 | new_fl = locks_alloc_lock(); | ||
814 | new_fl2 = locks_alloc_lock(); | ||
815 | } | ||
809 | 816 | ||
810 | lock_kernel(); | 817 | lock_kernel(); |
811 | if (request->fl_type != F_UNLCK) { | 818 | if (request->fl_type != F_UNLCK) { |