Browse Source

sc_hypervisor: fix resource leak when calling sc_hypervisor_get_type_of_workers()

Spotted by coverity.
Samuel Pitoiset 10 years ago
parent
commit
d423640859

+ 2 - 0
sc_hypervisor/src/hypervisor_policies/hard_coded_policy.c

@@ -64,6 +64,7 @@ void hard_coded_handle_idle_cycle(unsigned sched_ctx, int worker)
 
 //				sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, NULL, 1, tw);
 					sc_hypervisor_lp_distribute_floating_no_resources_in_ctxs(sc_hypervisor_get_sched_ctxs(), ns, tw->nw, w_in_s, NULL, nworkers, tw);
+					free(tw);
 				}
 			}	
 			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
@@ -97,6 +98,7 @@ static void hard_coded_handle_poped_task(unsigned sched_ctx, __attribute__((unus
 				w_in_s[1][1] = 0;
 //				sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, NULL, 1, tw);
 				sc_hypervisor_lp_distribute_floating_no_resources_in_ctxs(sc_hypervisor_get_sched_ctxs(), ns, tw->nw, w_in_s, NULL, nworkers, tw);
+				free(tw);
 			}
 			starpu_pthread_mutex_unlock(&act_hypervisor_mutex);
 		}

+ 2 - 0
sc_hypervisor/src/hypervisor_policies/teft_lp_policy.c

@@ -120,6 +120,7 @@ static void _size_ctxs(unsigned *sched_ctxs, int nsched_ctxs , int *workers, int
 	{
 		struct types_of_workers *tw = sc_hypervisor_get_types_of_workers(workers, nw);
 		sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, workers, 1, tw);
+		free(tw);
 	}
 	
 	for(i = 0; i < nw; i++)
@@ -237,6 +238,7 @@ static void _try_resizing(unsigned *sched_ctxs, int nsched_ctxs , int *workers,
 	{
 		struct types_of_workers *tw = sc_hypervisor_get_types_of_workers(workers, nw);
 		sc_hypervisor_lp_place_resources_in_ctx(ns, nw, w_in_s, sched_ctxs, workers, 0, tw);
+		free(tw);
 	}
 	
 	struct sc_hypervisor_policy_task_pool *next = NULL;