summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-08-20 02:47:34 +0300
committerJeff Layton <jlayton@kernel.org>2019-08-20 12:48:52 +0300
commitcfddf9f4c9f038c91c6c61d5cf3a161731b5c418 (patch)
tree3647a1cbff5b826fc3469f4a9583b2a163e40ed1
parentdf2474a22c42ce419b67067c52d71da06c385501 (diff)
downloadlinux-cfddf9f4c9f038c91c6c61d5cf3a161731b5c418.tar.xz
locks: fix a memory leak bug in __break_lease()
In __break_lease(), the file lock 'new_fl' is allocated in lease_alloc(). However, it is not deallocated in the following execution if smp_load_acquire() fails, leading to a memory leak bug. To fix this issue, free 'new_fl' before returning the error. Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu> Signed-off-by: Jeff Layton <jlayton@kernel.org>
-rw-r--r--fs/locks.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 24d1db632f6c..a364ebc5cec3 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1592,7 +1592,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
ctx = smp_load_acquire(&inode->i_flctx);
if (!ctx) {
WARN_ON_ONCE(1);
- return error;
+ goto free_lock;
}
percpu_down_read(&file_rwsem);
@@ -1672,6 +1672,7 @@ out:
spin_unlock(&ctx->flc_lock);
percpu_up_read(&file_rwsem);
locks_dispose_list(&dispose);
+free_lock:
locks_free_lock(new_fl);
return error;
}