title: Notification Chains code crashes system
body: <p>I wrote a simple code to capture the <code>netdevice</code> notifications and simply print their value out to the messages log file ... here's the code : </p>
  
  <pre><code>#include &lt;linux/notifier.h&gt;
  #include &lt;asm/kdebug.h&gt; 
  #include &lt;linux/netdevice.h&gt;
  #include &lt;linux/inetdevice.h&gt;
  
  int my_dev_event_handler (struct notifier_block *self,unsigned long val, void *data)
  {
      printk (KERN_INFO "my_dev_event: Val=%ld, Interface=%s\n", val,((struct net_device *) data)-&gt;name);
      return 0;
  }
  
  static struct notifier_block my_dev_notifier = {
  .notifier_call = my_dev_event_handler,
  };
  
  static int __init
  my_init (void)
  {
  printk(KERN_ALERT "***Module Loaded***\n");
  register_netdevice_notifier (&amp;my_dev_notifier); 
  
     return 0;
  }
  
  static void __exit my_end(void)
  {
      printk(KERN_ALERT "***Module Unloaded***\n");
  }
  
  module_init(my_init);
  module_exit(my_end);
  </code></pre>
  
  <p>this code compiles and runs correctly, it prints out the "my_dev_event:..." line every time a device goes up/off ... but sometimes (not always) the entire system freezes when a device goes up\down ... now I have two questions here: 
  1- why is the system freezing? anything wrong with this code?
  2- if there's a better way to notify my kernel module when a device goes connected/disconnected ...</p>