[Ocfs2-tools-devel] [PATCH 4/8 V2] Fix a memory leak problem in ocfs2_hb_ctl.c

piaojun piaojun at huawei.com
Sun Mar 29 18:49:39 PDT 2015


In main, hbo.dev_str, hbo.service and hbo.uuid_str should be freed after
use.

Signed-off-by: Jun Piao <piaojun at huawei.com>
Reviewed-by: Alex Chen <alex.chen at huawei.com>

---
 ocfs2_hb_ctl/ocfs2_hb_ctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ocfs2_hb_ctl/ocfs2_hb_ctl.c b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
index e4daa92..89bc2cf 100644
--- a/ocfs2_hb_ctl/ocfs2_hb_ctl.c
+++ b/ocfs2_hb_ctl/ocfs2_hb_ctl.c
@@ -631,6 +631,12 @@ int main(int argc, char **argv)
 	block_signals(SIG_UNBLOCK);

 bail:
+	if (hbo.dev_str)
+		ocfs2_free(&hbo.dev_str);
+	if (hbo.service)
+		ocfs2_free(&hbo.service);
+	if (hbo.uuid_str)
+		ocfs2_free(&hbo.uuid_str);
 	free_desc();
 	return ret ? 1 : 0;
 }
-- 1.8.4.3




More information about the Ocfs2-tools-devel mailing list