From b78643f9237fb3ae83e91f0e8f6799ed0f22cede Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 18 Sep 2006 15:55:41 +0000
Subject: [PATCH] minor memory leaks fixed

---
 src/api/step_ctx.c       | 23 +++--------------------
 src/common/job_options.c |  6 ++++--
 src/slurmctld/agent.c    |  1 +
 src/slurmctld/proc_req.c |  2 +-
 src/slurmctld/step_mgr.c |  8 +-------
 5 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/src/api/step_ctx.c b/src/api/step_ctx.c
index cd60cc2d7ab..abf401f8c7e 100644
--- a/src/api/step_ctx.c
+++ b/src/api/step_ctx.c
@@ -57,7 +57,6 @@ static void	_xcopy_char_array(char ***argv_p, char **argv, int cnt);
 static void	_xfree_char_array(char ***argv_p, int cnt);
 static job_step_create_request_msg_t *_copy_step_req(
 	job_step_create_request_msg_t *step_req);
-static void _free_step_req(job_step_create_request_msg_t *step_req);
 
 /*
  * slurm_step_ctx_create - Create a job step and its context. 
@@ -91,7 +90,7 @@ slurm_step_ctx_create (const job_step_create_request_msg_t *user_step_req)
 		if (net_stream_listen(&sock, &port) < 0) {
 			errnum = errno;
 			error("unable to intialize step context socket: %m");
-			_free_step_req(step_req);
+			slurm_free_job_step_create_request_msg(step_req);
 			goto fail;
 		}
 		step_req->port = port;
@@ -101,7 +100,7 @@ slurm_step_ctx_create (const job_step_create_request_msg_t *user_step_req)
 	if ((slurm_job_step_create(step_req, &step_resp) < 0) ||
 	    (step_resp == NULL)) {
 		errnum = errno;
-		_free_step_req(step_req);
+		slurm_free_job_step_create_request_msg(step_req);
 		goto fail;
 	}
 	
@@ -301,7 +300,7 @@ slurm_step_ctx_destroy (slurm_step_ctx ctx)
 		slurm_seterrno(EINVAL);
 		return SLURM_ERROR;
 	}
-	_free_step_req(ctx->step_req);
+	slurm_free_job_step_create_request_msg(ctx->step_req);
 	slurm_free_job_step_create_response_msg(ctx->step_resp);
 	if (ctx->argv)
 		_xfree_char_array(&ctx->argv, ctx->argc);
@@ -357,19 +356,3 @@ static job_step_create_request_msg_t *_copy_step_req(
 	return copy;
 }
 
-static void _free_step_req(job_step_create_request_msg_t *step_req)
-{
-	if (step_req == NULL)
-		return;
-
-	if (step_req->host != NULL)
-		xfree(step_req->host);
-	if (step_req->node_list != NULL)
-		xfree(step_req->node_list);
-	if (step_req->network != NULL)
-		xfree(step_req->network);
-	if (step_req->name != NULL)
-		xfree(step_req->name);
-
-	xfree(step_req);
-}
diff --git a/src/common/job_options.c b/src/common/job_options.c
index 4b86747256d..6ff046e37a7 100644
--- a/src/common/job_options.c
+++ b/src/common/job_options.c
@@ -203,9 +203,11 @@ int job_options_unpack (job_options_t opts, Buf buf)
 	if (unpackstr_xmalloc (&tag, &len, buf) != SLURM_SUCCESS)
 		return (SLURM_ERROR);
 
-	if (strncmp (tag, JOB_OPTIONS_PACK_TAG, len) != 0)
+	if (strncmp (tag, JOB_OPTIONS_PACK_TAG, len) != 0) {
+		xfree(tag);
 		return (-1);
-
+	}
+	xfree(tag);
 	unpack32 (&count, buf);
 
 	for (i = 0; i < count; i++) {
diff --git a/src/slurmctld/agent.c b/src/slurmctld/agent.c
index bfeea07397e..b79f4772906 100644
--- a/src/slurmctld/agent.c
+++ b/src/slurmctld/agent.c
@@ -546,6 +546,7 @@ static void *_wdog(void *args)
 	for (i = 0; i < agent_ptr->thread_count; i++) {
 		if (thread_ptr[i].ret_list)
 			list_destroy(thread_ptr[i].ret_list);
+		xfree(thread_ptr[i].nodelist);
 	}
 	
 	if (thd_comp.max_delay)
diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index d3035866f27..7da3508678a 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -1,5 +1,5 @@
 /*****************************************************************************\
- *  proc_msg.c - process incomming messages to slurmctld
+ *  proc_req.c - process incomming messages to slurmctld
  *
  *  $Id$
  *****************************************************************************
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index cdb4bb4e2d4..30c8796c857 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -529,9 +529,6 @@ _pick_step_nodes (struct job_record  *job_ptr,
 			node_tmp = bit_pick_cnt(nodes_idle,
 						(step_spec->node_count -
 						 nodes_picked_cnt));
-			debug2("1 got - %d %x",
-			       step_spec->node_count - nodes_picked_cnt,
-			       node_tmp);
 			if (node_tmp == NULL)
 				goto cleanup;
 			bit_or  (nodes_picked, node_tmp);
@@ -546,9 +543,6 @@ _pick_step_nodes (struct job_record  *job_ptr,
 			node_tmp = bit_pick_cnt(nodes_avail, 
 						(step_spec->node_count - 
 						 nodes_picked_cnt));
-			debug2("2 got - %d %x",
-			       step_spec->node_count - nodes_picked_cnt,
-			       node_tmp);
 			if (node_tmp == NULL)
 				goto cleanup;
 			bit_or  (nodes_picked, node_tmp);
@@ -770,7 +764,7 @@ step_create(job_step_create_request_msg_t *step_specs,
 	}
 	if (checkpoint_alloc_jobinfo (&step_ptr->check_job) < 0)
 		fatal ("step_create: checkpoint_alloc_jobinfo error");
-
+	xfree(step_node_list);
 	*new_step_record = step_ptr;
 	jobacct_g_step_start_slurmctld(step_ptr);
 	return SLURM_SUCCESS;
-- 
GitLab