Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
CORTX-33743: Analyze and fix memory leaks found in glibc when running…
Browse files Browse the repository at this point in the history
… s3 IOs with valgrind

Problem statement:
Valgrind reported few leaks in the code, where strdup was used for allocating memory to the duplicate string.

Fix Description:
Analyzed the code statically and freed up the variables allocated memory dynamically during the execution.
Attaching the valrind report with the code changes, where no leak is found wrt the leaks described of the JIRA ticket.
  • Loading branch information
swapnil-seagate committed Aug 18, 2022
1 parent de245d3 commit f93c6eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions ha/entrypoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ static int ha_entrypoint_client_fom_tick(struct m0_fom *fom)
fop->f_opaque = ecl;
next_state = M0_HEC_SEND_WAIT;
rc = m0_rpc_post(item) == 0 ? M0_FSO_WAIT : M0_FSO_AGAIN;
m0_free(req_fop_data->erf_git_rev_id.b_addr);
break;

case M0_HEC_SEND_WAIT:
Expand Down
8 changes: 5 additions & 3 deletions motr/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,10 @@ static int cs_storage_init(const char *stob_type,
/**
Finalises storage for a request handler in a motr context.
*/
static void cs_storage_fini(struct cs_stobs *stob)
static void cs_storage_fini(struct m0_reqh_context *rctx)
{
struct cs_stobs *stob = &rctx->rc_stob;
m0_free((char*)rctx->rc_addb_stlocation);
cs_storage_devs_fini();
if (stob->s_sdom != NULL)
m0_stob_domain_fini(stob->s_sdom);
Expand Down Expand Up @@ -1687,7 +1689,7 @@ static int cs_storage_setup(struct m0_motr *cctx)
cleanup_addb2:
m0_reqh_addb2_fini(&rctx->rc_reqh);
cleanup_stob:
cs_storage_fini(&rctx->rc_stob);
cs_storage_fini(rctx);
reqh_be_fini:
m0_reqh_be_fini(&rctx->rc_reqh);
be_fini:
Expand Down Expand Up @@ -2874,7 +2876,7 @@ static void cs_level_leave(struct m0_module *module)
break;
case CS_LEVEL_STORAGE_SETUP:
if (rctx->rc_state == RC_INITIALISED) {
cs_storage_fini(&rctx->rc_stob);
cs_storage_fini(rctx);
rctx->rc_reqh.rh_pools = NULL;
}
break;
Expand Down

0 comments on commit f93c6eb

Please sign in to comment.