Skip to content

Commit

Permalink
dlm: memory leaks on error path in dlm_user_request()
Browse files Browse the repository at this point in the history
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 597d0ca ("[DLM] dlm: user locks")
Cc: [email protected] # 2.6.19

Signed-off-by: Vasily Averin <[email protected]>
Signed-off-by: David Teigland <[email protected]>
  • Loading branch information
vaverin authored and teigland committed Nov 15, 2018
1 parent c017472 commit d47b41a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d47b41a

Please sign in to comment.