greybus: properly cleanup ida and idr structures when shutting down
authorGreg Kroah-Hartman <gregkh@google.com>
Wed, 8 Jul 2015 17:44:09 +0000 (10:44 -0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 8 Jul 2015 18:53:43 +0000 (11:53 -0700)
idr and ida structures have internal memory allocated that needs to be
freed when modules are removed.  So call the proper idr_destroy() or
ida_destroy() functions on the module exit path to free the memory.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
drivers/staging/greybus/raw.c
drivers/staging/greybus/uart.c
drivers/staging/greybus/vibrator.c

index d93d052a8a7e87abdf5aad85f43dfcae2736f551..3be96db2588ba97e500cb6d0cd4392f3acf34a6d 100644 (file)
@@ -364,6 +364,7 @@ static void __exit raw_exit(void)
        gb_protocol_deregister(&raw_protocol);
        unregister_chrdev_region(MKDEV(raw_major, 0), NUM_MINORS);
        class_destroy(raw_class);
+       ida_destroy(&minors);
 }
 module_exit(raw_exit);
 
index e2a456f8105c86f6842e59e0c9a4b90b0d4ee792..3932f8667d314317d47e644ae8af6c0e785093cb 100644 (file)
@@ -761,6 +761,7 @@ static void gb_tty_exit(void)
 {
        tty_unregister_driver(gb_tty_driver);
        put_tty_driver(gb_tty_driver);
+       idr_destroy(&tty_minors);
 }
 
 static struct gb_protocol uart_protocol = {
index 20f09bba5fac6b805a0104ea97e6c6c2b506c420..62b3552006fc8a93799ba7a0e432bdd85e8bd80b 100644 (file)
@@ -190,6 +190,7 @@ static __exit void protocol_exit(void)
 {
        gb_protocol_deregister(&vibrator_protocol);
        class_unregister(&vibrator_class);
+       ida_destroy(&minors);
 }
 module_exit(protocol_exit);