kernel timer function error

322 views Asked by At

I try to modify the tizen kernel. I am testing each line. So, I find mod_timer is kernel error What's the problem???

code is

  void timer_add(void){
      struct timer_list timer; 
      setup_timer(&timer, kill_callback, 0); 
      mod_timer(&timer, jiffies + msecs_to_jiffies(3000));
  }

 void kill_callback(unsigned long data)
{
    sys_kill(current->pid, SIGKILL);
    return ;
}

[ 19.029281] Unable to handle kernel NULL pointer dereference at virtual addre

1

There are 1 answers

0
NZD On

Your function timer_add declares local variable timer, which goes out of scope when the function returns. But you pass it as an argument to function setup_timer, where it is used to set up your call back function.

When the call back function is executed at a later time, it references your variable timer, which does not exist any more.

You either have to declare your variable timer as a static variable or use a global variable.