]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
oprofile: Free potentially owned tasks in case of errors
authorRobert Richter <robert.richter@amd.com>
Wed, 7 Dec 2011 17:30:10 +0000 (18:30 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 21 Dec 2011 21:04:51 +0000 (13:04 -0800)
commit 6ac6519b93065625119a347be1cbcc1b89edb773 upstream.

After registering the task free notifier we possibly have tasks in our
dying_tasks list. Free them after unregistering the notifier in case
of an error.

Signed-off-by: Robert Richter <robert.richter@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/oprofile/buffer_sync.c

index 5c4df24eae4bb0066fa34a616d9324996f4d5c07..6495ae0bd728b05df449b3751bbe5101995fca10 100644 (file)
@@ -140,6 +140,13 @@ static struct notifier_block module_load_nb = {
        .notifier_call = module_load_notify,
 };
 
+static void free_all_tasks(void)
+{
+       /* make sure we don't leak task structs */
+       process_task_mortuary();
+       process_task_mortuary();
+}
+
 int sync_start(void)
 {
        int err;
@@ -173,6 +180,7 @@ out3:
        profile_event_unregister(PROFILE_TASK_EXIT, &task_exit_nb);
 out2:
        task_handoff_unregister(&task_free_nb);
+       free_all_tasks();
 out1:
        free_cpumask_var(marked_cpus);
        goto out;
@@ -191,10 +199,7 @@ void sync_stop(void)
        mutex_unlock(&buffer_mutex);
        flush_scheduled_work();
 
-       /* make sure we don't leak task structs */
-       process_task_mortuary();
-       process_task_mortuary();
-
+       free_all_tasks();
        free_cpumask_var(marked_cpus);
 }