From 2a31f6a8a92fa88a75d3218c2a876c819326396a Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 14 Nov 2003 17:07:07 +0000 Subject: [PATCH] Fix a few memory leaks (needed to free credential in several more places). Plus some minor code clean-up with no changes to logic. --- src/api/allocate.c | 6 +++++- src/api/cancel.c | 3 ++- src/api/complete.c | 3 ++- src/api/config_info.c | 2 +- src/api/job_info.c | 3 ++- src/api/job_step_info.c | 2 +- src/api/node_info.c | 2 +- src/api/partition_info.c | 2 +- src/api/reconfigure.c | 4 +++- src/api/submit.c | 1 + 10 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/api/allocate.c b/src/api/allocate.c index 0895109f3f3..cecf35dcf12 100644 --- a/src/api/allocate.c +++ b/src/api/allocate.c @@ -89,6 +89,7 @@ slurm_allocate_resources (job_desc_msg_t *req, if (rc == SLURM_SOCKET_ERROR) return SLURM_SOCKET_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_SLURM_RC: if (_handle_rc_msg(&resp_msg) < 0) @@ -127,6 +128,7 @@ int slurm_job_will_run (job_desc_msg_t *req, if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_SOCKET_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_SLURM_RC: if (_handle_rc_msg(&resp_msg) < 0) @@ -183,7 +185,7 @@ slurm_allocate_resources_and_run (job_desc_msg_t *req, if (rc == SLURM_SOCKET_ERROR) return SLURM_SOCKET_ERROR; - + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_SLURM_RC: if (_handle_rc_msg(&resp_msg) < 0) @@ -222,6 +224,7 @@ slurm_job_step_create (job_step_create_request_msg_t *req, if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_SLURM_RC: if (_handle_rc_msg(&resp_msg) < 0) @@ -259,6 +262,7 @@ slurm_confirm_allocation (old_job_alloc_msg_t *req, if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch(resp_msg.msg_type) { case RESPONSE_SLURM_RC: if (_handle_rc_msg(&resp_msg) < 0) diff --git a/src/api/cancel.c b/src/api/cancel.c index fb364e2888c..79258b70191 100644 --- a/src/api/cancel.c +++ b/src/api/cancel.c @@ -73,7 +73,8 @@ slurm_kill_job_step (uint32_t job_id, uint32_t step_id, uint16_t signal) if (slurm_send_recv_controller_rc_msg(&msg, &rc) < 0) return SLURM_FAILURE; - if (rc) slurm_seterrno_ret(rc); + if (rc) + slurm_seterrno_ret(rc); return SLURM_SUCCESS; } diff --git a/src/api/complete.c b/src/api/complete.c index 3c529677c4b..de75377c9d9 100644 --- a/src/api/complete.c +++ b/src/api/complete.c @@ -85,7 +85,8 @@ slurm_complete_job_step ( uint32_t job_id, uint32_t step_id, if (slurm_send_recv_controller_rc_msg(&req_msg, &rc) < 0) return SLURM_ERROR; - if (rc) slurm_seterrno_ret(rc); + if (rc) + slurm_seterrno_ret(rc); return SLURM_PROTOCOL_SUCCESS; } diff --git a/src/api/config_info.c b/src/api/config_info.c index 90e467231a7..28cf509dca3 100644 --- a/src/api/config_info.c +++ b/src/api/config_info.c @@ -153,10 +153,10 @@ slurm_load_ctl_conf (time_t update_time, slurm_ctl_conf_t **confp) if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_BUILD_INFO: *confp = (slurm_ctl_conf_info_msg_t *) resp_msg.data; - slurm_free_cred(resp_msg.cred); break; case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; diff --git a/src/api/job_info.c b/src/api/job_info.c index 853a2a2fb6f..5c5e1b50eec 100644 --- a/src/api/job_info.c +++ b/src/api/job_info.c @@ -244,10 +244,10 @@ slurm_load_jobs (time_t update_time, job_info_msg_t **resp) if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_JOB_INFO: *resp = (job_info_msg_t *)resp_msg.data; - slurm_free_cred(resp_msg.cred); break; case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; @@ -292,6 +292,7 @@ slurm_pid2jobid (pid_t job_pid, uint32_t *jobid) if (slurm_send_recv_node_msg(&req_msg, &resp_msg, 0) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_JOB_ID: *jobid = ((job_id_response_msg_t *) resp_msg.data)->job_id; diff --git a/src/api/job_step_info.c b/src/api/job_step_info.c index f07cea90b61..9f517b0a6cf 100644 --- a/src/api/job_step_info.c +++ b/src/api/job_step_info.c @@ -125,10 +125,10 @@ slurm_get_job_steps (time_t update_time, uint32_t job_id, uint32_t step_id, if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_JOB_STEP_INFO: *resp = (job_step_info_response_msg_t *) resp_msg.data; - slurm_free_cred(resp_msg.cred); break; case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; diff --git a/src/api/node_info.c b/src/api/node_info.c index f220ff62a63..91ce0d846f7 100644 --- a/src/api/node_info.c +++ b/src/api/node_info.c @@ -129,10 +129,10 @@ slurm_load_node (time_t update_time, node_info_msg_t **resp) if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_NODE_INFO: *resp = (node_info_msg_t *) resp_msg.data; - slurm_free_cred(resp_msg.cred); break; case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; diff --git a/src/api/partition_info.c b/src/api/partition_info.c index d9c01cbbb7c..0d66f643c6f 100644 --- a/src/api/partition_info.c +++ b/src/api/partition_info.c @@ -161,10 +161,10 @@ slurm_load_partitions (time_t update_time, partition_info_msg_t **resp) if (slurm_send_recv_controller_msg(&req_msg, &resp_msg) < 0) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_PARTITION_INFO: *resp = (partition_info_msg_t *) resp_msg.data; - slurm_free_cred(resp_msg.cred); break; case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; diff --git a/src/api/reconfigure.c b/src/api/reconfigure.c index 37f027563cf..b9109b428aa 100644 --- a/src/api/reconfigure.c +++ b/src/api/reconfigure.c @@ -58,7 +58,8 @@ slurm_reconfigure ( void ) if (slurm_send_recv_controller_rc_msg(&req, &rc) < 0) return SLURM_ERROR; - if (rc) slurm_seterrno_ret(rc); + if (rc) + slurm_seterrno_ret(rc); return SLURM_PROTOCOL_SUCCESS; } @@ -129,6 +130,7 @@ _send_message_controller (enum controller_id dest, slurm_msg_t *req) if ((rc = slurm_receive_msg(fd, &resp_msg, 0)) < 0) slurm_seterrno_ret(SLURMCTLD_COMMUNICATIONS_RECEIVE_ERROR); + slurm_free_cred(resp_msg.cred); if (slurm_shutdown_msg_conn(fd) != SLURM_SUCCESS) slurm_seterrno_ret(SLURMCTLD_COMMUNICATIONS_SHUTDOWN_ERROR); diff --git a/src/api/submit.c b/src/api/submit.c index c413cff5065..f49926b20f5 100644 --- a/src/api/submit.c +++ b/src/api/submit.c @@ -87,6 +87,7 @@ slurm_submit_batch_job (job_desc_msg_t *req, if (rc == SLURM_SOCKET_ERROR) return SLURM_ERROR; + slurm_free_cred(resp_msg.cred); switch (resp_msg.msg_type) { case RESPONSE_SLURM_RC: rc = ((return_code_msg_t *) resp_msg.data)->return_code; -- GitLab