diff
+ static void cleanup_gpio_chardev_data(struct gpio_chardev_data *cdev)
+ {
+ 	if (cdev->watched_lines) {
+ 		bitmap_free(cdev->watched_lines);
+ 		cdev->watched_lines = NULL;
+ 	}
+ }
+
  static int gpio_chrdev_release(struct inode *inode, struct file *file)
  {
  	struct gpio_chardev_data *cdev = file->private_data;
  	struct gpio_device *gdev = cdev->gdev;
  
- 	bitmap_free(cdev->watched_lines);
  	blocking_notifier_chain_unregister(&gdev->device_notifier,
 					   &cdev->device_unregistered_nb);
  	blocking_notifier_chain_unregister(&gdev->line_state_notifier,
 					   &cdev->lineinfo_changed_nb);
  	gpio_device_put(gdev);
+ 	cleanup_gpio_chardev_data(cdev);
  	kfree(cdev);
  }
