aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2013-04-07 15:46:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-08 14:30:04 -0400
commit1b581f173992cded311f810346378f763a1f1e5d (patch)
tree84ef80845e97f17fcc4daeb3338721807910c28c
parentc12f9ea28e9fbe7b1f4cefc953bee33298370683 (diff)
tty: mxser: fix cycle termination condition in mxser_probe() and mxser_module_init()
There is a bug in resources deallocation code in mxser_probe() and mxser_module_init(). As soon as variable 'i' is unsigned int, cycle termination condition i >= 0 is always true. The patch fixes the issue. Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Acked-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/mxser.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 484b6a3c9b03..302909ccf183 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2643,9 +2643,9 @@ static int mxser_probe(struct pci_dev *pdev,
2643 mxvar_sdriver, brd->idx + i, &pdev->dev); 2643 mxvar_sdriver, brd->idx + i, &pdev->dev);
2644 if (IS_ERR(tty_dev)) { 2644 if (IS_ERR(tty_dev)) {
2645 retval = PTR_ERR(tty_dev); 2645 retval = PTR_ERR(tty_dev);
2646 for (i--; i >= 0; i--) 2646 for (; i > 0; i--)
2647 tty_unregister_device(mxvar_sdriver, 2647 tty_unregister_device(mxvar_sdriver,
2648 brd->idx + i); 2648 brd->idx + i - 1);
2649 goto err_relbrd; 2649 goto err_relbrd;
2650 } 2650 }
2651 } 2651 }
@@ -2751,9 +2751,9 @@ static int __init mxser_module_init(void)
2751 tty_dev = tty_port_register_device(&brd->ports[i].port, 2751 tty_dev = tty_port_register_device(&brd->ports[i].port,
2752 mxvar_sdriver, brd->idx + i, NULL); 2752 mxvar_sdriver, brd->idx + i, NULL);
2753 if (IS_ERR(tty_dev)) { 2753 if (IS_ERR(tty_dev)) {
2754 for (i--; i >= 0; i--) 2754 for (; i > 0; i--)
2755 tty_unregister_device(mxvar_sdriver, 2755 tty_unregister_device(mxvar_sdriver,
2756 brd->idx + i); 2756 brd->idx + i - 1);
2757 for (i = 0; i < brd->info->nports; i++) 2757 for (i = 0; i < brd->info->nports; i++)
2758 tty_port_destroy(&brd->ports[i].port); 2758 tty_port_destroy(&brd->ports[i].port);
2759 free_irq(brd->irq, brd); 2759 free_irq(brd->irq, brd);