Commit 64698b69 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Linus Torvalds

[PATCH] serial moxa: fix leaks of struct tty_driver

Fix leak of struct tty_driver in mxser_init & mxser_module_exit
Signed-off-by: default avatarKirill Smelkov <kirr@mns.spb.ru>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 57432345
...@@ -494,14 +494,18 @@ static int __init mxser_module_init(void) ...@@ -494,14 +494,18 @@ static int __init mxser_module_init(void)
static void __exit mxser_module_exit(void) static void __exit mxser_module_exit(void)
{ {
int i, err = 0; int i, err;
if (verbose) if (verbose)
printk(KERN_DEBUG "Unloading module mxser ...\n"); printk(KERN_DEBUG "Unloading module mxser ...\n");
if ((err |= tty_unregister_driver(mxvar_sdriver))) err = tty_unregister_driver(mxvar_sdriver);
if (!err)
put_tty_driver(mxvar_sdriver);
else
printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n"); printk(KERN_ERR "Couldn't unregister MOXA Smartio/Industio family serial driver\n");
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++) {
struct pci_dev *pdev; struct pci_dev *pdev;
...@@ -690,7 +694,6 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs ...@@ -690,7 +694,6 @@ static int mxser_get_PCI_conf(int busnum, int devnum, int board_type, struct mxs
static int mxser_init(void) static int mxser_init(void)
{ {
int i, m, retval, b, n; int i, m, retval, b, n;
int ret1;
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
int index; int index;
unsigned char busnum, devnum; unsigned char busnum, devnum;
...@@ -854,14 +857,11 @@ static int mxser_init(void) ...@@ -854,14 +857,11 @@ static int mxser_init(void)
} }
#endif #endif
ret1 = 0; retval = tty_register_driver(mxvar_sdriver);
if (!(ret1 = tty_register_driver(mxvar_sdriver))) { if (retval) {
return 0;
} else
printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n"); printk(KERN_ERR "Couldn't install MOXA Smartio/Industio family driver !\n");
put_tty_driver(mxvar_sdriver);
if (ret1) {
for (i = 0; i < MXSER_BOARDS; i++) { for (i = 0; i < MXSER_BOARDS; i++) {
if (mxsercfg[i].board_type == -1) if (mxsercfg[i].board_type == -1)
continue; continue;
...@@ -870,10 +870,10 @@ static int mxser_init(void) ...@@ -870,10 +870,10 @@ static int mxser_init(void)
//todo: release io, vector //todo: release io, vector
} }
} }
return -1; return retval;
} }
return (0); return 0;
} }
static void mxser_do_softint(void *private_) static void mxser_do_softint(void *private_)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment