title: Use unregister_chrdev_region in case registration failed
body: <p>I am learning how to write kernel drivers, and I have a doubt about the proper 
  usage of the function unregister_chrdev_region.</p>
  
  <p>Right now I have a simple test module with just the init and 
  exit functions:</p>
  
  <pre><code>static dev_t devn; 
  
  int __init my_dev_init(void)
  {
      devn = MKDEV(0,0); 
  
      if(alloc_chrdev_region(&amp;devn,0,1,"my_dev") != 0)
      {
          return -EBUSY; 
      }
      else
      {
          return 0; 
      }
  }
  
  void __exit my_dev_exit(void)
  {
     unregister_chrdev_region(devn,1);  
   }
  </code></pre>
  
  <p>My question: is it safe to call unregister_chrdev_region if the registration failed ? I would assume no, but pretty much all example code that I have seen calls unregister_chrdev_region no matter what happened during the initialization.</p>