aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/isicom.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-11-15 03:49:55 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-15 20:20:58 -0500
commitd0f59141ca40159c9d142c0f62e9aea61f846539 (patch)
tree0d1a37909ac7157b8f38eb94d9a285224dcc383a /drivers/tty/isicom.c
parentde274bfe0fc81def6ddb8a17020a9a4b56477cc4 (diff)
TTY: isicom, fix tty buffers memory leak
After commit "TTY: move tty buffers to tty_port", the tty buffers are not freed in some drivers. This is because tty_port_destructor is not called whenever a tty_port is freed. This was an assumption I counted with but was unfortunately untrue. So fix the drivers to fulfil this assumption. This one is special as we need more work to be done. Previously, the tty_port was initialized at module load time, but to be able to destroy the port and init it again, we now do the initialization in probe and destroy in remove. I.e. at more appropriate places for that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/isicom.c')
-rw-r--r--drivers/tty/isicom.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index 5f3ecbc2713e..67f288d7e76a 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -1610,10 +1610,15 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1610 if (retval < 0) 1610 if (retval < 0)
1611 goto errunri; 1611 goto errunri;
1612 1612
1613 for (index = 0; index < board->port_count; index++) 1613 for (index = 0; index < board->port_count; index++) {
1614 tty_port_register_device(&board->ports[index].port, 1614 struct tty_port *tport = &board->ports[index].port;
1615 isicom_normal, board->index * 16 + index, 1615 tty_port_init(tport);
1616 &pdev->dev); 1616 tport->ops = &isicom_port_ops;
1617 tport->close_delay = 50 * HZ/100;
1618 tport->closing_wait = 3000 * HZ/100;
1619 tty_port_register_device(tport, isicom_normal,
1620 board->index * 16 + index, &pdev->dev);
1621 }
1617 1622
1618 return 0; 1623 return 0;
1619 1624
@@ -1635,8 +1640,10 @@ static void __devexit isicom_remove(struct pci_dev *pdev)
1635 struct isi_board *board = pci_get_drvdata(pdev); 1640 struct isi_board *board = pci_get_drvdata(pdev);
1636 unsigned int i; 1641 unsigned int i;
1637 1642
1638 for (i = 0; i < board->port_count; i++) 1643 for (i = 0; i < board->port_count; i++) {
1639 tty_unregister_device(isicom_normal, board->index * 16 + i); 1644 tty_unregister_device(isicom_normal, board->index * 16 + i);
1645 tty_port_destroy(&board->ports[i].port);
1646 }
1640 1647
1641 free_irq(board->irq, board); 1648 free_irq(board->irq, board);
1642 pci_release_region(pdev, 3); 1649 pci_release_region(pdev, 3);
@@ -1655,13 +1662,9 @@ static int __init isicom_init(void)
1655 isi_card[idx].ports = port; 1662 isi_card[idx].ports = port;
1656 spin_lock_init(&isi_card[idx].card_lock); 1663 spin_lock_init(&isi_card[idx].card_lock);
1657 for (channel = 0; channel < 16; channel++, port++) { 1664 for (channel = 0; channel < 16; channel++, port++) {
1658 tty_port_init(&port->port);
1659 port->port.ops = &isicom_port_ops;
1660 port->magic = ISICOM_MAGIC; 1665 port->magic = ISICOM_MAGIC;
1661 port->card = &isi_card[idx]; 1666 port->card = &isi_card[idx];
1662 port->channel = channel; 1667 port->channel = channel;
1663 port->port.close_delay = 50 * HZ/100;
1664 port->port.closing_wait = 3000 * HZ/100;
1665 port->status = 0; 1668 port->status = 0;
1666 /* . . . */ 1669 /* . . . */
1667 } 1670 }