[PATCH] VFS: Fix memory leak with file leases
authorJ. Bruce Fields <bfields@fieldses.org>
Fri, 11 Nov 2005 00:08:00 +0000 (19:08 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sun, 13 Nov 2005 17:29:54 +0000 (12:29 -0500)
 The patch
 http://linux.bkbits.net:8080/linux-2.6/diffs/fs/locks.c@1.70??nav=index.html
 introduced a pretty nasty memory leak in the lease code. When freeing
 the lease, the code in locks_delete_lock() will correctly clean up
 the fasync queue, but when we return to fcntl_setlease(), the freed
 fasync entry will be reinstated.

 This patch ensures that we skip the call to fasync_helper() when we're
 freeing up the lease.

Signed-off-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/locks.c

index a1e8b2248014c0aa1d7ae8b2766440f753929908..600d1fbe35710e98fb6d9d2d95de816b59f029b8 100644 (file)
@@ -1430,7 +1430,7 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
        lock_kernel();
 
        error = __setlease(filp, arg, &flp);
-       if (error)
+       if (error || arg == F_UNLCK)
                goto out_unlock;
 
        error = fasync_helper(fd, filp, 1, &flp->fl_fasync);