Commit bf9ffe26 authored by John Levon's avatar John Levon Committed by Linus Torvalds

[PATCH] OProfile: fix init / exit routine

Ensure that the arch exit routines are always called when needed,
previously we could end up with a nasty crash if using oprofile.timer=1,
or the FS register failed.
parent b043632b
......@@ -131,36 +131,33 @@ extern void timer_init(struct oprofile_operations ** ops);
static int __init oprofile_init(void)
{
int err = -ENODEV;
if (!timer) {
/* Architecture must fill in the interrupt ops and the
* logical CPU type, or we can fall back to the timer
* interrupt profiler.
*/
err = oprofile_arch_init(&oprofile_ops);
}
/* Architecture must fill in the interrupt ops and the
* logical CPU type, or we can fall back to the timer
* interrupt profiler.
*/
int err = oprofile_arch_init(&oprofile_ops);
if (err == -ENODEV) {
if (err == -ENODEV || timer) {
timer_init(&oprofile_ops);
err = 0;
}
if (err)
} else if (err) {
goto out;
}
if (!oprofile_ops->cpu_type) {
printk(KERN_ERR "oprofile: cpu_type not set !\n");
err = -EFAULT;
goto out;
} else {
err = oprofilefs_register();
}
err = oprofilefs_register();
if (err)
goto out;
if (err)
goto out_exit;
out:
return err;
out_exit:
oprofile_arch_exit();
goto out;
}
......
......@@ -40,7 +40,9 @@ struct oprofile_operations {
/**
* One-time initialisation. *ops must be set to a filled-in
* operations structure.
* operations structure. This is called even in timer interrupt
* mode.
*
* Return 0 on success.
*/
int oprofile_arch_init(struct oprofile_operations ** ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment