title: Can cdev_init fail
body: <p>I am trying initialize a character device, and after going through some debugging, it seems that there is a possibility that I am failing to register the character device properly</p>
  
  <pre><code>int rc;
  char device_name[32] = "dma_proxy";
  static struct class *local_class_p = NULL;
  
  /* Allocate a character device from the kernel for this 
   * driver
   */ 
  rc = alloc_chrdev_region(&amp;pchannel_p-&gt;dev_node, 0, 1, "dma_proxy");
  
  if (rc) {
      printk(KERN_INFO "unable to get a char device number\n");
      return rc;
  }
  
  /* Initialize the ter device data structure before
   * registering the character device with the kernel
   */ 
  printk("pchannel_p-&gt;cdev addr: %p\n", (void*)&amp;pchannel_p-&gt;cdev);
  cdev_init(&amp;pchannel_p-&gt;cdev, &amp;dm_fops);
  pchannel_p-&gt;cdev.owner = THIS_MODULE;
  rc = cdev_add(&amp;pchannel_p-&gt;cdev, pchannel_p-&gt;dev_node, 1);
  
  if (rc) {
      printk(KERN_INFO "unable to add char device\n");
      goto init_error1;
  }
  
  /* Only one class in sysfs is to be created for multiple channels,
   * create the device in sysfs which will allow the device node 
   * in /dev to be created 
   */
  if (!local_class_p) {
      local_class_p = class_create(THIS_MODULE, DRIVER_NAME);
  
      if (IS_ERR(pchannel_p-&gt;dma_device_p-&gt;class)) {
          printk(KERN_INFO, "unable to create class\n");
          rc = ERROR;
          goto init_error2;
      }   
  }
  
  pchannel_p-&gt;class_p = local_class_p;
  
  /* Create the device node in /dev so the device is accessible 
   * as a character device
   */
  strcat(device_name, name);
  pchannel_p-&gt;proxy_device_p = device_create(pchannel_p-&gt;class_p, NULL,
                          pchannel_p-&gt;dev_node, NULL, device_name);
  
  if (IS_ERR(pchannel_p-&gt;proxy_device_p)) {
      printk(KERN_INFO "unable to create the device\n");
      goto init_error3;
  }
  </code></pre>
  
  <p>However, perhaps this is not the case. In the open function I print, the i_cdev address of the inode and it matches the printed address in this function.</p>
  
  <pre><code>static int local_open(struct inode *ino, struct file *file)
  {
  
      file-&gt;private_data = container_of(ino-&gt;i_cdev, struct dma_proxy_channel, cdev);
      printk("Inode-&gt;cdev addr: %p", (void*)ino-&gt;i_cdev);
  
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <p>pchannel_p->cdev addr: ee9b7194</p>
  
  <p>Inode->cdev addr: ee9b7194</p>
  
  <p>How might I know if my device initialization failed? The /dev/ node is there and in the /sys folder so is the class I created </p>