Skip to content

Commit f608998

Browse files
Colin Ian Kingteigland
authored andcommitted
fs: dlm: Fix memory leak of object mh
There is an error return path that is not kfree'ing mh after it has been successfully allocates. Fix this by moving the call to create_rcom to after the check on rc_in->rc_id check to avoid this. Thanks to Alexander Ahring Oder Aring for suggesting the correct way to fix this. Addresses-Coverity: ("Resource leak") Fixes: a070a91 ("fs: dlm: add more midcomms hooks") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 706474f commit f608998

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/dlm/rcom.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,17 @@ static void receive_rcom_lookup(struct dlm_ls *ls, struct dlm_rcom *rc_in)
385385
int error, ret_nodeid, nodeid = rc_in->rc_header.h_nodeid;
386386
int len = rc_in->rc_header.h_length - sizeof(struct dlm_rcom);
387387

388-
error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh);
389-
if (error)
390-
return;
391-
392388
/* Old code would send this special id to trigger a debug dump. */
393389
if (rc_in->rc_id == 0xFFFFFFFF) {
394390
log_error(ls, "receive_rcom_lookup dump from %d", nodeid);
395391
dlm_dump_rsb_name(ls, rc_in->rc_buf, len);
396392
return;
397393
}
398394

395+
error = create_rcom(ls, nodeid, DLM_RCOM_LOOKUP_REPLY, 0, &rc, &mh);
396+
if (error)
397+
return;
398+
399399
error = dlm_master_lookup(ls, nodeid, rc_in->rc_buf, len,
400400
DLM_LU_RECOVER_MASTER, &ret_nodeid, NULL);
401401
if (error)

0 commit comments

Comments
 (0)