]> git.itanic.dy.fi Git - linux-stable/commitdiff
locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
authorJeff Layton <jeff.layton@primarydata.com>
Wed, 4 Mar 2015 22:34:32 +0000 (17:34 -0500)
committerJeff Layton <jeff.layton@primarydata.com>
Wed, 4 Mar 2015 22:34:32 +0000 (17:34 -0500)
Commit 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
introduced a regression in the handling of lease upgrade/downgrades.

In the event that we already have a lease on a file and are going to
either upgrade or downgrade it, we skip doing any list insertion or
deletion and simply re-call lm_setup on the existing lease.

As of commit 8634b51f6ca2 however, we end up calling lm_setup on the
lease that was passed in, instead of on the existing lease. This causes
us to leak the fasync_struct that was allocated in the event that there
was not already an existing one (as it always appeared that there
wasn't one).

Fixes: 8634b51f6ca2 (locks: convert lease handling to file_lock_context)
Reported-and-Tested-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
fs/locks.c

index 365c82e1b3a9a602057e65edc9b857c6adce6b76..f1bad681fc1ca3df14eda4be6542088425e901d2 100644 (file)
@@ -1665,7 +1665,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
        }
 
        if (my_fl != NULL) {
-               error = lease->fl_lmops->lm_change(my_fl, arg, &dispose);
+               lease = my_fl;
+               error = lease->fl_lmops->lm_change(lease, arg, &dispose);
                if (error)
                        goto out;
                goto out_setup;