diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-04-19 10:50:57 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-04-19 10:50:57 -0400 |
commit | 0c35f7af8bba0a06c5b307e71549cbae3d3ff171 (patch) | |
tree | ad6c31ac280ef4784d36e00a28b19a5f264554d7 | |
parent | 37c715bc201539cbb1b8ebe80b05d05d20211443 (diff) |
Avoid use-after-free in C-EDF deallocate.
Some day, we should implement proper plugin switching...
For now, this should suffice to avoid crashes.
-rw-r--r-- | litmus/sched_cedf.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index c715ec1e0ee2..fba4fd5b2a59 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c | |||
@@ -605,24 +605,21 @@ static void print_cluster_topology(cpumask_var_t mask, int cpu) | |||
605 | } | 605 | } |
606 | #endif | 606 | #endif |
607 | 607 | ||
608 | static int clusters_allocated = 0; | ||
609 | |||
608 | static void cleanup_cedf(void) | 610 | static void cleanup_cedf(void) |
609 | { | 611 | { |
610 | int i; | 612 | int i; |
611 | for (i = 0; i < num_clusters; i++) { | ||
612 | kfree(cedf[i].cpus); | ||
613 | kfree(cedf[i].heap_node); | ||
614 | free_cpumask_var(cedf[i].cpu_map); | ||
615 | } | ||
616 | 613 | ||
617 | kfree(cedf); | 614 | if (clusters_allocated) { |
618 | } | 615 | for (i = 0; i < num_clusters; i++) { |
619 | 616 | kfree(cedf[i].cpus); | |
620 | static long cedf_deactivate_plugin(void) | 617 | kfree(cedf[i].heap_node); |
621 | { | 618 | free_cpumask_var(cedf[i].cpu_map); |
622 | cleanup_cedf(); | 619 | } |
623 | printk(KERN_INFO "C-EDF: Deactivate Plugin\n"); | ||
624 | 620 | ||
625 | return 0; | 621 | kfree(cedf); |
622 | } | ||
626 | } | 623 | } |
627 | 624 | ||
628 | static long cedf_activate_plugin(void) | 625 | static long cedf_activate_plugin(void) |
@@ -633,6 +630,9 @@ static long cedf_activate_plugin(void) | |||
633 | cpumask_var_t mask; | 630 | cpumask_var_t mask; |
634 | int chk = 0; | 631 | int chk = 0; |
635 | 632 | ||
633 | /* de-allocate old clusters, if any */ | ||
634 | cleanup_cedf(); | ||
635 | |||
636 | printk(KERN_INFO "C-EDF: Activate Plugin, cache index = %d\n", | 636 | printk(KERN_INFO "C-EDF: Activate Plugin, cache index = %d\n", |
637 | cluster_cache_index); | 637 | cluster_cache_index); |
638 | 638 | ||
@@ -722,6 +722,7 @@ static long cedf_activate_plugin(void) | |||
722 | } | 722 | } |
723 | 723 | ||
724 | free_cpumask_var(mask); | 724 | free_cpumask_var(mask); |
725 | clusters_allocated = 1; | ||
725 | return 0; | 726 | return 0; |
726 | } | 727 | } |
727 | 728 | ||
@@ -738,7 +739,6 @@ static struct sched_plugin cedf_plugin __cacheline_aligned_in_smp = { | |||
738 | .task_block = cedf_task_block, | 739 | .task_block = cedf_task_block, |
739 | .admit_task = cedf_admit_task, | 740 | .admit_task = cedf_admit_task, |
740 | .activate_plugin = cedf_activate_plugin, | 741 | .activate_plugin = cedf_activate_plugin, |
741 | .deactivate_plugin = cedf_deactivate_plugin, | ||
742 | }; | 742 | }; |
743 | 743 | ||
744 | 744 | ||