locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
Subsystems (2)
PATCH 1/1 locks: fix fasync_struct memory leak in lease upgrade/downgrade handling
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 skip to re-calling 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).
--- fs/locks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/locks.c +2 -1
@@ -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;
Signature · 1 line
2.1.0
Hi Jeff,
Quoted 7 lines · Jeff Layton
Commit
8634b51f6ca2(locks: convert lease handling tofile_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 skip to re-calling
lm_setupon the existing lease.
Quoted 7 lines
As of commit
8634b51f6ca2however, we end up callinglm_setupon the lease that was passed in, instead of on the existing lease. This causes us to leak thefasync_structthat 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)
Yes, that fixes the problem. Thanks!
Quoted 2 lines
Reported-by Daniel Wagner <[email protected]>Signed-off-by Jeff Layton <[email protected]>
cheers,
daniel
Quoted 20 lines · On Thu, 5 Mar 2015 07:57:09 +0100 Daniel Wagner <[email protected]>…
Hi Jeff,
Quoted 7 lines · Jeff Layton
Commit
8634b51f6ca2(locks: convert lease handling tofile_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 skip to re-calling
lm_setupon the existing lease.Quoted 7 lines
As of commit
8634b51f6ca2however, we end up callinglm_setupon the lease that was passed in, instead of on the existing lease. This causes us to leak thefasync_structthat 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)Yes, that fixes the problem. Thanks!
Quoted 8 lines
Quoted 2 lines
Reported-by Daniel Wagner <[email protected]>Signed-off-by Jeff Layton <[email protected]>Tested-by Daniel Wagner <[email protected]>cheers,
daniel
Thanks for testing it! I'll let it soak in linux-next for a day or so and then send a pull request to Linus.
Cheers!
Signature · 1 line
Jeff Layton <[email protected]>