release_region in RocketPort char driver
PATCH 1/1 release_region in RocketPort char driver
Hi Andrew/Comtrol people :),
Patch against 2.6.0-test6.
- Release a previous requested region if tty_register_driver fails.
Found by smatch
Please consider applying,
Thanks.
Felipe
drivers/char/rocket.c renamed from drivers/char/rocket.c.orig +1 -0
@@ -2468,6 +2468,7 @@if (retval <0 ) {printk (KERN_INFO "Couldn't install tty RocketPort driver (error %d)\n" , -retval);put_tty_driver (rocket_driver); +release_region (controller,4 );return -1 ; }
Quoted 10 lines · Felipe W Damasio
--- linux-2.6.0-test6/drivers/char/rocket.c.orig 2003-10-06 10:57:29.000000000 -0300
+++linux-2.6.0-test6/drivers/char/rocket.c2003-10-06 11:00:29.000000000 -0300
@@ -2468,6 +2468,7 @@
if (retval < 0) {
printk(KERN_INFO "Couldn't install tty RocketPort driver (error %d)\n", -retval);put_tty_driver(rocket_driver);
+release_region(controller, 4);
return -1;
}
a) If variable `controller' is zero then we never allocated this region, so we should not free it.
b) There is an error exit path further on which also needs to release this region (if controller != 0).
Hi Andrew,
Quoted 6 lines · Andrew Morton
Felipe W Damasio <[email protected]> wrote:
a) If variable `controller' is zero then we never allocated this region, so we should not free it.b) There is an error exit path further on which also needs to release this region (if controller != 0).
Right. Please review this patch, then. Against 2.6.0-test7. Thanks,
Felipe
drivers/char/rocket.c renamed from drivers/char/rocket.c.orig +4 -0
@@ -2466,6 +2466,8 @@if (retval <0 ) {printk (KERN_INFO "Couldn't install tty RocketPort driver (error %d)\n" , -retval);put_tty_driver (rocket_driver); +if (controller) +release_region (controller,4 );return -1 ; }
@@ -2497,6 +2499,8 @@del_timer_sync (&rocket_timer);tty_unregister_driver (rocket_driver);put_tty_driver (rocket_driver); +if (controller) +release_region (controller,4 );return -ENXIO ; }