|
@@ -319,8 +319,16 @@ void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
|
|
|
|
|
|
void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
|
|
|
{
|
|
|
- int is_kernel = !user_mode(regs);
|
|
|
- unsigned long pc = profile_pc(regs);
|
|
|
+ int is_kernel;
|
|
|
+ unsigned long pc;
|
|
|
+
|
|
|
+ if (likely(regs)) {
|
|
|
+ is_kernel = !user_mode(regs);
|
|
|
+ pc = profile_pc(regs);
|
|
|
+ } else {
|
|
|
+ is_kernel = 0; /* This value will not be used */
|
|
|
+ pc = ESCAPE_CODE; /* as this causes an early return. */
|
|
|
+ }
|
|
|
|
|
|
__oprofile_add_ext_sample(pc, regs, event, is_kernel);
|
|
|
}
|