summaryrefslogtreecommitdiff
path: root/fs/dlm
diff options
context:
space:
mode:
authorVasily Averin <vvs@virtuozzo.com>2018-11-15 13:18:56 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-13 10:03:52 +0100
commit579d0aacc4f58a8aa83d5762895ed80dc6775bfc (patch)
tree259d52fbabf0663677b0cdc3d5cf12d4837c770c /fs/dlm
parent0f090eb97008318eb3dbf53aa4cde990f547ac69 (diff)
dlm: memory leaks on error path in dlm_user_request()
commit d47b41aceeadc6b58abc9c7c6485bef7cfb75636 upstream. According to comment in dlm_user_request() ua should be freed in dlm_free_lkb() after successful attach to lkb. However ua is attached to lkb not in set_lock_args() but later, inside request_lock(). Fixes 597d0cae0f99 ("[DLM] dlm: user locks") Cc: stable@kernel.org # 2.6.19 Signed-off-by: Vasily Averin <vvs@virtuozzo.com> Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/dlm')
-rw-r--r--fs/dlm/lock.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 1e6a3a391849..3a7f401e943c 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -5795,20 +5795,20 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
goto out;
}
}
-
- /* After ua is attached to lkb it will be freed by dlm_free_lkb().
- When DLM_IFL_USER is set, the dlm knows that this is a userspace
- lock and that lkb_astparam is the dlm_user_args structure. */
-
error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs,
fake_astfn, ua, fake_bastfn, &args);
- lkb->lkb_flags |= DLM_IFL_USER;
-
if (error) {
+ kfree(ua->lksb.sb_lvbptr);
+ ua->lksb.sb_lvbptr = NULL;
+ kfree(ua);
__put_lkb(ls, lkb);
goto out;
}
+ /* After ua is attached to lkb it will be freed by dlm_free_lkb().
+ When DLM_IFL_USER is set, the dlm knows that this is a userspace
+ lock and that lkb_astparam is the dlm_user_args structure. */
+ lkb->lkb_flags |= DLM_IFL_USER;
error = request_lock(ls, lkb, name, namelen, &args);
switch (error) {