nfsd: Fix a memory leak of struct file_lock

This change “nfsd: Fix a memory leak of struct file_lock” in Linux kernel is authored by Kinglong Mee <kinglongmee [at]> on Mon Jul 13 17:30:51 2015 +0800.

nfsd: Fix a memory leak of struct file_lock

Signed-off-by: Kinglong Mee <>
Signed-off-by: J. Bruce Fields <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit af9dbaf.

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 fs/nfsd/nfs4state.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 61dfb33..84fb6eb 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3934,6 +3934,7 @@ static int nfs4_setlease(struct nfs4_delegation *dp)
 	if (!filp) {
 		/* We should always have a readable file here */
+		locks_free_lock(fl);
 		return -EBADF;
 	fl->fl_file = filp;

The commit for this change in Linux stable tree is af9dbaf (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *