Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] cs5535_gpio.c: call cdev_del() during module_exit to unmap kobject references and other cleanups

During module unloading, cdev_del() must be called to unmap cdev related
kobject references and other cleanups(such as inode->i_cdev being set to
NULL) which prevents the OOPS upon subsequent loading, usage and unloading
of modules(as seen in the mail thread
http://marc.theaimsgroup.com/?l=linux-kernel&m=114533640609018&w=2).

Also, remove unneeded test of gpio_base.

Signed-off-by: Thayumanavar Sachithanantham <thayumk@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Thayumanavar Sachithanantham and committed by
Linus Torvalds
03246800 c16c556e

+3 -2
+3 -2
drivers/char/cs5535_gpio.c
··· 241 241 static void __exit cs5535_gpio_cleanup(void) 242 242 { 243 243 dev_t dev_id = MKDEV(major, 0); 244 + 245 + cdev_del(&cs5535_gpio_cdev); 244 246 unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT); 245 - if (gpio_base != 0) 246 - release_region(gpio_base, CS5535_GPIO_SIZE); 247 + release_region(gpio_base, CS5535_GPIO_SIZE); 247 248 } 248 249 249 250 module_init(cs5535_gpio_init);