Skip to content

Commit

Permalink
CORTX-33741: Fix memory leaks for emap using s3 IOs with valgrind (Se…
Browse files Browse the repository at this point in the history
…agate#2063)

* Fix leaks for emap_it_get_cb().
* Fix memory leak for root node in balloc-ut.
* Remove unwanted code.

Signed-off-by: Upendra Patwardhan <upendra.patwardhan@seagate.com>
  • Loading branch information
upendrapatwardhan authored Aug 9, 2022
1 parent 241a3ac commit 5423084
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions balloc/ut/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ int test_balloc_ut_ops(struct m0_be_ut_backend *ut_be, struct m0_be_seg *seg,
grp = m0_be_ut_backend_sm_group_lookup(ut_be);
rc = m0_balloc_create(0, seg, grp, &motr_balloc, &M0_FID_INIT(0, 1));
M0_UT_ASSERT(rc == 0);
motr_balloc->cb_ballroom.ab_ops->bo_fini(&motr_balloc->cb_ballroom);

rc = motr_balloc->cb_ballroom.ab_ops->bo_init
(&motr_balloc->cb_ballroom, seg, BALLOC_DEF_BLOCK_SHIFT,
Expand Down
10 changes: 7 additions & 3 deletions be/extmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,9 +1225,9 @@ static int emap_it_open(struct m0_be_emap_cursor *it, int prev_rc)
ext->ee_val = rec->er_value;
ext->ee_cksum_buf.b_nob = rec->er_cksum_nob;
ext->ee_cksum_buf.b_addr = rec->er_cksum_nob ?
(void *)&rec->er_footer : NULL;
(void *)&rec->er_footer : NULL;
it->ec_unit_size = rec->er_unit_size;
if (!emap_it_prefix_ok(it))
if (!emap_it_prefix_ok(it))
rc = -ESRCH;
}
it->ec_op.bo_u.u_emap.e_rc = rc;
Expand All @@ -1254,7 +1254,7 @@ static void emap_it_init(struct m0_be_emap_cursor *it,
static void be_emap_close(struct m0_be_emap_cursor *it)
{
if (it->ec_recbuf.b_addr != NULL ) {
m0_buf_free(&it->ec_recbuf);
m0_buf_free(&it->ec_recbuf);
}

m0_btree_cursor_fini(&it->ec_cursor);
Expand Down Expand Up @@ -1537,6 +1537,10 @@ be_emap_split(struct m0_be_emap_cursor *it,
rc = emap_it_get(it);

it->ec_op.bo_u.u_emap.e_rc = rc;
if (it->ec_recbuf.b_addr != NULL) {
m0_buf_free(&it->ec_recbuf);
it->ec_recbuf.b_addr = NULL;
}
return M0_RC(rc);
}

Expand Down
1 change: 1 addition & 0 deletions stob/ad.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ static int stob_ad_domain_create(struct m0_stob_type *type,
*/
rc = m0_balloc_create(dom_key, seg, grp, &cb,
&cfg->adg_id.si_fid);
cb->cb_ballroom.ab_ops->bo_fini(&cb->cb_ballroom);
rc = rc ?: m0_be_tx_exclusive_open_sync(&tx);

M0_ASSERT(adom == NULL);
Expand Down

0 comments on commit 5423084

Please sign in to comment.