diff --git a/src/plugins/gres/gpu/gres_gpu.c b/src/plugins/gres/gpu/gres_gpu.c index db297c762806bc996a75ea647cf7a7676800042b..4337ff801f8db383adb801d655c615675b7bdf36 100644 --- a/src/plugins/gres/gpu/gres_gpu.c +++ b/src/plugins/gres/gpu/gres_gpu.c @@ -567,7 +567,7 @@ extern int node_reconfig(char *node_name, char *orig_config, char **new_config, { int rc = SLURM_SUCCESS; gpu_node_state_t *gres_ptr; - char *node_gres_config, *tok, *last = NULL; + char *node_gres_config = NULL, *tok = NULL, *last = NULL; int32_t gres_config_cnt = 0; xassert(gres_data); @@ -578,9 +578,10 @@ extern int node_reconfig(char *node_name, char *orig_config, char **new_config, gres_ptr->gpu_cnt_config = NO_VAL; gres_ptr->gpu_cnt_found = NO_VAL; } - - node_gres_config = xstrdup(orig_config); - tok = strtok_r(node_gres_config, ",", &last); + if (orig_config) { + node_gres_config = xstrdup(orig_config); + tok = strtok_r(node_gres_config, ",", &last); + } while (tok) { if (!strcmp(tok, "gpu")) { gres_config_cnt = 1; @@ -725,7 +726,8 @@ extern void node_state_dealloc(void *gres_data) gres_ptr->gpu_cnt_alloc = 0; if (gres_ptr->gpu_bit_alloc) { int i = bit_size(gres_ptr->gpu_bit_alloc) - 1; - bit_nclear(gres_ptr->gpu_bit_alloc, 0, i); + if (i > 0) + bit_nclear(gres_ptr->gpu_bit_alloc, 0, i); } } diff --git a/src/plugins/gres/nic/gres_nic.c b/src/plugins/gres/nic/gres_nic.c index 966e32d7058274bc7786c1c63fdc3cfa94ac19c2..adeb729c3ce299410a667293809d37cfb353612a 100644 --- a/src/plugins/gres/nic/gres_nic.c +++ b/src/plugins/gres/nic/gres_nic.c @@ -567,7 +567,7 @@ extern int node_reconfig(char *node_name, char *orig_config, char **new_config, { int rc = SLURM_SUCCESS; nic_node_state_t *gres_ptr; - char *node_gres_config, *tok, *last = NULL; + char *node_gres_config = NULL, *tok = NULL, *last = NULL; int32_t gres_config_cnt = 0; xassert(gres_data); @@ -579,8 +579,10 @@ extern int node_reconfig(char *node_name, char *orig_config, char **new_config, gres_ptr->nic_cnt_found = NO_VAL; } - node_gres_config = xstrdup(orig_config); - tok = strtok_r(node_gres_config, ",", &last); + if (orig_config) { + node_gres_config = xstrdup(orig_config); + tok = strtok_r(node_gres_config, ",", &last); + } while (tok) { if (!strcmp(tok, "nic")) { gres_config_cnt = 1; @@ -725,7 +727,8 @@ extern void node_state_dealloc(void *gres_data) gres_ptr->nic_cnt_alloc = 0; if (gres_ptr->nic_bit_alloc) { int i = bit_size(gres_ptr->nic_bit_alloc) - 1; - bit_nclear(gres_ptr->nic_bit_alloc, 0, i); + if (i > 0) + bit_nclear(gres_ptr->nic_bit_alloc, 0, i); } }