Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

TTY: call tty_port_destroy in the rest of drivers

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.

To be sure, the TTY buffers (and later some stuff) are gone along with
the tty_port, we have to call tty_port_destroy at tear-down places.
This is mostly where the structure containing a tty_port is freed.
This patch does exactly that -- put tty_port_destroy at those places.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby and committed by
Greg Kroah-Hartman
191c5f10 d0f59141

+139 -40
+4 -1
arch/alpha/kernel/srmcons.c
··· 205 205 static int __init 206 206 srmcons_init(void) 207 207 { 208 - tty_port_init(&srmcons_singleton.port); 209 208 setup_timer(&srmcons_singleton.timer, srmcons_receive_chars, 210 209 (unsigned long)&srmcons_singleton); 211 210 if (srm_is_registered_console) { ··· 214 215 driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES); 215 216 if (!driver) 216 217 return -ENOMEM; 218 + 219 + tty_port_init(&srmcons_singleton.port); 220 + 217 221 driver->driver_name = "srm"; 218 222 driver->name = "srm"; 219 223 driver->major = 0; /* dynamic */ ··· 229 227 err = tty_register_driver(driver); 230 228 if (err) { 231 229 put_tty_driver(driver); 230 + tty_port_destroy(&srmcons_singleton.port); 232 231 return err; 233 232 } 234 233 srmcons_driver = driver;
+1
arch/ia64/hp/sim/simserial.c
··· 555 555 return 0; 556 556 err_free_tty: 557 557 put_tty_driver(hp_simserial_driver); 558 + tty_port_destroy(&state->port); 558 559 return retval; 559 560 } 560 561
+4 -2
arch/m68k/emu/nfcon.c
··· 120 120 { 121 121 int res; 122 122 123 - tty_port_init(&nfcon_tty_port); 124 - 125 123 stderr_id = nf_get_id("NF_STDERR"); 126 124 if (!stderr_id) 127 125 return -ENODEV; ··· 127 129 nfcon_tty_driver = alloc_tty_driver(1); 128 130 if (!nfcon_tty_driver) 129 131 return -ENOMEM; 132 + 133 + tty_port_init(&nfcon_tty_port); 130 134 131 135 nfcon_tty_driver->driver_name = "nfcon"; 132 136 nfcon_tty_driver->name = "nfcon"; ··· 143 143 if (res) { 144 144 pr_err("failed to register nfcon tty driver\n"); 145 145 put_tty_driver(nfcon_tty_driver); 146 + tty_port_destroy(&nfcon_tty_port); 146 147 return res; 147 148 } 148 149 ··· 158 157 unregister_console(&nf_console); 159 158 tty_unregister_driver(nfcon_tty_driver); 160 159 put_tty_driver(nfcon_tty_driver); 160 + tty_port_destroy(&nfcon_tty_port); 161 161 } 162 162 163 163 module_init(nfcon_init);
+3 -2
arch/parisc/kernel/pdc_cons.c
··· 186 186 printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n"); 187 187 pdc_cons.flags &= ~CON_BOOT; 188 188 189 - tty_port_init(&tty_port); 190 - 191 189 pdc_console_tty_driver = alloc_tty_driver(1); 192 190 193 191 if (!pdc_console_tty_driver) 194 192 return -ENOMEM; 193 + 194 + tty_port_init(&tty_port); 195 195 196 196 pdc_console_tty_driver->driver_name = "pdc_cons"; 197 197 pdc_console_tty_driver->name = "ttyB"; ··· 207 207 err = tty_register_driver(pdc_console_tty_driver); 208 208 if (err) { 209 209 printk(KERN_ERR "Unable to register the PDC console TTY driver\n"); 210 + tty_port_destroy(&tty_port); 210 211 return err; 211 212 } 212 213
+2
arch/um/drivers/line.c
··· 584 584 printk(KERN_ERR "register_lines : can't register %s driver\n", 585 585 line_driver->name); 586 586 put_tty_driver(driver); 587 + for (i = 0; i < nlines; i++) 588 + tty_port_destroy(&lines[i].port); 587 589 return err; 588 590 } 589 591
+1
arch/xtensa/platforms/iss/console.c
··· 221 221 printk("ISS_SERIAL: failed to unregister serial driver (%d)\n", 222 222 error); 223 223 put_tty_driver(serial_driver); 224 + tty_port_destroy(&serial_port); 224 225 } 225 226 226 227
+3 -1
drivers/char/ttyprintk.c
··· 179 179 { 180 180 int ret = -ENOMEM; 181 181 182 - tty_port_init(&tpk_port.port); 183 182 tpk_port.port.ops = &null_ops; 184 183 mutex_init(&tpk_port.port_write_mutex); 185 184 ··· 188 189 TTY_DRIVER_UNNUMBERED_NODE); 189 190 if (IS_ERR(ttyprintk_driver)) 190 191 return PTR_ERR(ttyprintk_driver); 192 + 193 + tty_port_init(&tpk_port.port); 191 194 192 195 ttyprintk_driver->driver_name = "ttyprintk"; 193 196 ttyprintk_driver->name = "ttyprintk"; ··· 212 211 error: 213 212 tty_unregister_driver(ttyprintk_driver); 214 213 put_tty_driver(ttyprintk_driver); 214 + tty_port_destroy(&tpk_port.port); 215 215 ttyprintk_driver = NULL; 216 216 return ret; 217 217 }
+6 -4
drivers/isdn/gigaset/common.c
··· 518 518 kfree(cs->bcs); 519 519 f_cs: gig_dbg(DEBUG_INIT, "freeing cs"); 520 520 mutex_unlock(&cs->mutex); 521 + tty_port_destroy(&cs->port); 521 522 free_cs(cs); 522 523 } 523 524 EXPORT_SYMBOL_GPL(gigaset_freecs); ··· 752 751 gig_dbg(DEBUG_INIT, "setting up iif"); 753 752 if (gigaset_isdn_regdev(cs, modulename) < 0) { 754 753 pr_err("error registering ISDN device\n"); 755 - goto error; 754 + goto error_port; 756 755 } 757 756 758 757 make_valid(cs, VALID_ID); 759 758 ++cs->cs_init; 760 759 gig_dbg(DEBUG_INIT, "setting up hw"); 761 760 if (cs->ops->initcshw(cs) < 0) 762 - goto error; 761 + goto error_port; 763 762 764 763 ++cs->cs_init; 765 764 ··· 774 773 gig_dbg(DEBUG_INIT, "setting up bcs[%d]", i); 775 774 if (gigaset_initbcs(cs->bcs + i, cs, i) < 0) { 776 775 pr_err("could not allocate channel %d data\n", i); 777 - goto error; 776 + goto error_port; 778 777 } 779 778 } 780 779 ··· 787 786 788 787 gig_dbg(DEBUG_INIT, "cs initialized"); 789 788 return cs; 790 - 789 + error_port: 790 + tty_port_destroy(&cs->port); 791 791 error: 792 792 gig_dbg(DEBUG_INIT, "failed"); 793 793 gigaset_freecs(cs);
+4
drivers/isdn/i4l/isdn_tty.c
··· 1849 1849 kfree(info->fax); 1850 1850 #endif 1851 1851 kfree(info->port.xmit_buf - 4); 1852 + info->port.xmit_buf = NULL; 1853 + tty_port_destroy(&info->port); 1852 1854 } 1853 1855 tty_unregister_driver(m->tty_modem); 1854 1856 err: ··· 1872 1870 kfree(info->fax); 1873 1871 #endif 1874 1872 kfree(info->port.xmit_buf - 4); 1873 + info->port.xmit_buf = NULL; 1874 + tty_port_destroy(&info->port); 1875 1875 } 1876 1876 tty_unregister_driver(dev->mdm.tty_modem); 1877 1877 put_tty_driver(dev->mdm.tty_modem);
+5 -2
drivers/misc/pti.c
··· 882 882 static void __devexit pti_pci_remove(struct pci_dev *pdev) 883 883 { 884 884 struct pti_dev *drv_data = pci_get_drvdata(pdev); 885 + unsigned int a; 885 886 886 887 unregister_console(&pti_console); 887 888 888 - tty_unregister_device(pti_tty_driver, 0); 889 - tty_unregister_device(pti_tty_driver, 1); 889 + for (a = 0; a < PTITTY_MINOR_NUM; a++) { 890 + tty_unregister_device(pti_tty_driver, a); 891 + tty_port_destroy(&drv_data->port[a]); 892 + } 890 893 891 894 iounmap(drv_data->pti_ioaddr); 892 895 pci_set_drvdata(pdev, NULL);
+3 -2
drivers/net/usb/hso.c
··· 2274 2274 /* unlink and free TX URB */ 2275 2275 usb_free_urb(serial->tx_urb); 2276 2276 kfree(serial->tx_data); 2277 + tty_port_destroy(&serial->port); 2277 2278 } 2278 2279 2279 2280 static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, ··· 2284 2283 int minor; 2285 2284 int i; 2286 2285 2286 + tty_port_init(&serial->port); 2287 + 2287 2288 minor = get_free_serial_index(); 2288 2289 if (minor < 0) 2289 2290 goto exit; 2290 - 2291 - tty_port_init(&serial->port); 2292 2291 2293 2292 /* register our minor number */ 2294 2293 serial->parent->dev = tty_port_register_device(&serial->port, tty_drv,
+1
drivers/s390/char/con3215.c
··· 677 677 { 678 678 kfree(raw->inbuf); 679 679 kfree(raw->buffer); 680 + tty_port_destroy(&raw->port); 680 681 kfree(raw); 681 682 } 682 683
+3 -1
drivers/s390/char/sclp_tty.c
··· 547 547 sclp_tty_tolower = 1; 548 548 } 549 549 sclp_tty_chars_count = 0; 550 - tty_port_init(&sclp_port); 551 550 552 551 rc = sclp_register(&sclp_input_event); 553 552 if (rc) { 554 553 put_tty_driver(driver); 555 554 return rc; 556 555 } 556 + 557 + tty_port_init(&sclp_port); 557 558 558 559 driver->driver_name = "sclp_line"; 559 560 driver->name = "sclp_line"; ··· 572 571 rc = tty_register_driver(driver); 573 572 if (rc) { 574 573 put_tty_driver(driver); 574 + tty_port_destroy(&sclp_port); 575 575 return rc; 576 576 } 577 577 sclp_tty_driver = driver;
+2
drivers/s390/char/sclp_vt220.c
··· 615 615 return; 616 616 sclp_unregister(&sclp_vt220_register); 617 617 __sclp_vt220_free_pages(); 618 + tty_port_destroy(&sclp_vt220_port); 618 619 } 619 620 620 621 /* Allocate buffer pages and register with sclp core. Controlled by init ··· 651 650 if (rc) { 652 651 __sclp_vt220_free_pages(); 653 652 sclp_vt220_init_count--; 653 + tty_port_destroy(&sclp_vt220_port); 654 654 } 655 655 return rc; 656 656 }
+2
drivers/s390/char/tty3270.c
··· 722 722 while (pages--) 723 723 free_pages((unsigned long) tp->freemem_pages[pages], 0); 724 724 kfree(tp->freemem_pages); 725 + tty_port_destroy(&tp->port); 725 726 out_tp: 726 727 kfree(tp); 727 728 out_err: ··· 745 744 for (pages = 0; pages < TTY3270_STRING_PAGES; pages++) 746 745 free_pages((unsigned long) tp->freemem_pages[pages], 0); 747 746 kfree(tp->freemem_pages); 747 + tty_port_destroy(&tp->port); 748 748 kfree(tp); 749 749 } 750 750
+4 -1
drivers/staging/ccg/u_serial.c
··· 1140 1140 1141 1141 return status; 1142 1142 fail: 1143 - while (count--) 1143 + while (count--) { 1144 + tty_port_destroy(&ports[count].port->port); 1144 1145 kfree(ports[count].port); 1146 + } 1145 1147 put_tty_driver(gs_tty_driver); 1146 1148 gs_tty_driver = NULL; 1147 1149 return status; ··· 1197 1195 1198 1196 WARN_ON(port->port_usb != NULL); 1199 1197 1198 + tty_port_destroy(&port->port); 1200 1199 kfree(port); 1201 1200 } 1202 1201 n_ports = 0;
+2
drivers/staging/dgrp/dgrp_specproc.c
··· 752 752 753 753 return 0; 754 754 755 + /* FIXME this guy should free the tty driver stored in nd and destroy 756 + * all channel ports */ 755 757 error_out: 756 758 kfree(nd); 757 759 return ret;
+3 -1
drivers/staging/dgrp/dgrp_tty.c
··· 3119 3119 void 3120 3120 dgrp_tty_uninit(struct nd_struct *nd) 3121 3121 { 3122 + unsigned int i; 3122 3123 char id[3]; 3123 3124 3124 3125 ID_TO_CHAR(nd->nd_ID, id); ··· 3153 3152 put_tty_driver(nd->nd_xprint_ttdriver); 3154 3153 nd->nd_ttdriver_flags &= ~XPRINT_TTDRV_REG; 3155 3154 } 3155 + for (i = 0; i < CHAN_MAX; i++) 3156 + tty_port_destroy(&nd->nd_chan[i].port); 3156 3157 } 3157 3158 3158 3159 ··· 3337 3334 3338 3335 init_waitqueue_head(&(ch->ch_pun.un_open_wait)); 3339 3336 init_waitqueue_head(&(ch->ch_pun.un_close_wait)); 3340 - tty_port_init(&ch->port); 3341 3337 tty_port_init(&ch->port); 3342 3338 } 3343 3339 return 0;
+2
drivers/staging/ipack/devices/ipoctal.c
··· 446 446 tty_dev = tty_port_register_device(&channel->tty_port, tty, i, NULL); 447 447 if (IS_ERR(tty_dev)) { 448 448 dev_err(&ipoctal->dev->dev, "Failed to register tty device.\n"); 449 + tty_port_destroy(&channel->tty_port); 449 450 continue; 450 451 } 451 452 dev_set_drvdata(tty_dev, channel); ··· 742 741 struct ipoctal_channel *channel = &ipoctal->channel[i]; 743 742 tty_unregister_device(ipoctal->tty_drv, i); 744 743 tty_port_free_xmit_buf(&channel->tty_port); 744 + tty_port_destroy(&channel->tty_port); 745 745 } 746 746 747 747 tty_unregister_driver(ipoctal->tty_drv);
+2
drivers/tty/amiserial.c
··· 1771 1771 fail_unregister: 1772 1772 tty_unregister_driver(serial_driver); 1773 1773 fail_put_tty_driver: 1774 + tty_port_destroy(&state->tport); 1774 1775 put_tty_driver(serial_driver); 1775 1776 return error; 1776 1777 } ··· 1786 1785 printk("SERIAL: failed to unregister serial driver (%d)\n", 1787 1786 error); 1788 1787 put_tty_driver(serial_driver); 1788 + tty_port_destroy(&state->tport); 1789 1789 1790 1790 free_irq(IRQ_AMIGA_TBE, state); 1791 1791 free_irq(IRQ_AMIGA_RBF, state);
+4 -2
drivers/tty/bfin_jtag_comm.c
··· 240 240 { 241 241 int ret; 242 242 243 - tty_port_init(&port); 244 - 245 243 bfin_jc_kthread = kthread_create(bfin_jc_emudat_manager, NULL, DRV_NAME); 246 244 if (IS_ERR(bfin_jc_kthread)) 247 245 return PTR_ERR(bfin_jc_kthread); ··· 254 256 bfin_jc_driver = alloc_tty_driver(1); 255 257 if (!bfin_jc_driver) 256 258 goto err_driver; 259 + 260 + tty_port_init(&port); 257 261 258 262 bfin_jc_driver->driver_name = DRV_NAME; 259 263 bfin_jc_driver->name = DEV_NAME; ··· 274 274 return 0; 275 275 276 276 err: 277 + tty_port_destroy(&port); 277 278 put_tty_driver(bfin_jc_driver); 278 279 err_driver: 279 280 kfree(bfin_jc_write_buf.buf); ··· 290 289 kfree(bfin_jc_write_buf.buf); 291 290 tty_unregister_driver(bfin_jc_driver); 292 291 put_tty_driver(bfin_jc_driver); 292 + tty_port_destroy(&port); 293 293 } 294 294 module_exit(bfin_jc_exit); 295 295
+5 -3
drivers/tty/cyclades.c
··· 3934 3934 static void __devexit cy_pci_remove(struct pci_dev *pdev) 3935 3935 { 3936 3936 struct cyclades_card *cinfo = pci_get_drvdata(pdev); 3937 - unsigned int i; 3937 + unsigned int i, channel; 3938 3938 3939 3939 /* non-Z with old PLX */ 3940 3940 if (!cy_is_Z(cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == ··· 3960 3960 pci_release_regions(pdev); 3961 3961 3962 3962 cinfo->base_addr = NULL; 3963 - for (i = cinfo->first_line; i < cinfo->first_line + 3964 - cinfo->nports; i++) 3963 + for (channel = 0, i = cinfo->first_line; i < cinfo->first_line + 3964 + cinfo->nports; i++, channel++) { 3965 3965 tty_unregister_device(cy_serial_driver, i); 3966 + tty_port_destroy(&cinfo->ports[channel].port); 3967 + } 3966 3968 cinfo->nports = 0; 3967 3969 kfree(cinfo->ports); 3968 3970 }
+2
drivers/tty/ehv_bytechan.c
··· 757 757 return 0; 758 758 759 759 error: 760 + tty_port_destroy(&bc->port); 760 761 irq_dispose_mapping(bc->tx_irq); 761 762 irq_dispose_mapping(bc->rx_irq); 762 763 ··· 771 770 772 771 tty_unregister_device(ehv_bc_driver, bc - bcs); 773 772 773 + tty_port_destroy(&bc->port); 774 774 irq_dispose_mapping(bc->tx_irq); 775 775 irq_dispose_mapping(bc->rx_irq); 776 776
+1
drivers/tty/hvc/hvsi.c
··· 1218 1218 if (hp->virq == 0) { 1219 1219 printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n", 1220 1220 __func__, irq[0]); 1221 + tty_port_destroy(&hp->port); 1221 1222 continue; 1222 1223 } 1223 1224
+1
drivers/tty/ipwireless/tty.c
··· 566 566 ipwireless_disassociate_network_ttys(network, 567 567 ttyj->channel_idx); 568 568 tty_unregister_device(ipw_tty_driver, j); 569 + tty_port_destroy(&ttyj->port); 569 570 ttys[j] = NULL; 570 571 mutex_unlock(&ttyj->ipw_tty_mutex); 571 572 kfree(ttyj);
+4
drivers/tty/moxa.c
··· 895 895 896 896 return 0; 897 897 err_free: 898 + for (i = 0; i < MAX_PORTS_PER_BOARD; i++) 899 + tty_port_destroy(&brd->ports[i].port); 898 900 kfree(brd->ports); 899 901 err: 900 902 return ret; ··· 921 919 tty_kref_put(tty); 922 920 } 923 921 } 922 + for (a = 0; a < MAX_PORTS_PER_BOARD; a++) 923 + tty_port_destroy(&brd->ports[a].port); 924 924 while (1) { 925 925 opened = 0; 926 926 for (a = 0; a < brd->numPorts; a++)
+17 -8
drivers/tty/mxser.c
··· 2411 2411 2412 2412 retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser", 2413 2413 brd); 2414 - if (retval) 2414 + if (retval) { 2415 + for (i = 0; i < brd->info->nports; i++) 2416 + tty_port_destroy(&brd->ports[i].port); 2415 2417 printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " 2416 2418 "conflict with another device.\n", 2417 2419 brd->info->name, brd->irq); 2420 + } 2418 2421 2419 2422 return retval; 2423 + } 2424 + 2425 + static void mxser_board_remove(struct mxser_board *brd) 2426 + { 2427 + unsigned int i; 2428 + 2429 + for (i = 0; i < brd->info->nports; i++) { 2430 + tty_unregister_device(mxvar_sdriver, brd->idx + i); 2431 + tty_port_destroy(&brd->ports[i].port); 2432 + } 2420 2433 } 2421 2434 2422 2435 static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) ··· 2662 2649 { 2663 2650 #ifdef CONFIG_PCI 2664 2651 struct mxser_board *brd = pci_get_drvdata(pdev); 2665 - unsigned int i; 2666 2652 2667 - for (i = 0; i < brd->info->nports; i++) 2668 - tty_unregister_device(mxvar_sdriver, brd->idx + i); 2653 + mxser_board_remove(brd); 2669 2654 2670 2655 free_irq(pdev->irq, brd); 2671 2656 pci_release_region(pdev, 2); ··· 2759 2748 2760 2749 static void __exit mxser_module_exit(void) 2761 2750 { 2762 - unsigned int i, j; 2751 + unsigned int i; 2763 2752 2764 2753 pci_unregister_driver(&mxser_driver); 2765 2754 2766 2755 for (i = 0; i < MXSER_BOARDS; i++) /* ISA remains */ 2767 2756 if (mxser_boards[i].info != NULL) 2768 - for (j = 0; j < mxser_boards[i].info->nports; j++) 2769 - tty_unregister_device(mxvar_sdriver, 2770 - mxser_boards[i].idx + j); 2757 + mxser_board_remove(&mxser_boards[i]); 2771 2758 tty_unregister_driver(mxvar_sdriver); 2772 2759 put_tty_driver(mxvar_sdriver); 2773 2760
+9 -4
drivers/tty/nozomi.c
··· 1479 1479 if (IS_ERR(tty_dev)) { 1480 1480 ret = PTR_ERR(tty_dev); 1481 1481 dev_err(&pdev->dev, "Could not allocate tty?\n"); 1482 + tty_port_destroy(&port->port); 1482 1483 goto err_free_tty; 1483 1484 } 1484 1485 } ··· 1487 1486 return 0; 1488 1487 1489 1488 err_free_tty: 1490 - for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) 1491 - tty_unregister_device(ntty_driver, i); 1489 + for (i = 0; i < MAX_PORT; ++i) { 1490 + tty_unregister_device(ntty_driver, dc->index_start + i); 1491 + tty_port_destroy(&dc->port[i].port); 1492 + } 1492 1493 err_free_kfifo: 1493 1494 for (i = 0; i < MAX_PORT; i++) 1494 1495 kfifo_free(&dc->port[i].fifo_ul); ··· 1523 1520 complete off a hangup method ? */ 1524 1521 while (dc->open_ttys) 1525 1522 msleep(1); 1526 - for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) 1527 - tty_unregister_device(ntty_driver, i); 1523 + for (i = 0; i < MAX_PORT; ++i) { 1524 + tty_unregister_device(ntty_driver, dc->index_start + i); 1525 + tty_port_destroy(&dc->port[i].port); 1526 + } 1528 1527 } 1529 1528 1530 1529 /* Deallocate memory for one device */
+2
drivers/tty/rocket.c
··· 673 673 if (sInitChan(ctlp, &info->channel, aiop, chan) == 0) { 674 674 printk(KERN_ERR "RocketPort sInitChan(%d, %d, %d) failed!\n", 675 675 board, aiop, chan); 676 + tty_port_destroy(&info->port); 676 677 kfree(info); 677 678 return; 678 679 } ··· 2358 2357 for (i = 0; i < MAX_RP_PORTS; i++) 2359 2358 if (rp_table[i]) { 2360 2359 tty_unregister_device(rocket_driver, i); 2360 + tty_port_destroy(&rp_table[i]->port); 2361 2361 kfree(rp_table[i]); 2362 2362 } 2363 2363
+2
drivers/tty/serial/68328serial.c
··· 1225 1225 1226 1226 if (tty_register_driver(serial_driver)) { 1227 1227 put_tty_driver(serial_driver); 1228 + for (i = 0; i < NR_PORTS; i++) 1229 + tty_port_destroy(&m68k_soft[i].tport); 1228 1230 printk(KERN_ERR "Couldn't register serial driver\n"); 1229 1231 return -ENOMEM; 1230 1232 }
+4 -1
drivers/tty/serial/ifx6x60.c
··· 829 829 { 830 830 if (ifx_dev->tty_dev) 831 831 tty_unregister_device(tty_drv, ifx_dev->minor); 832 + tty_port_destroy(&ifx_dev->tty_port); 832 833 kfifo_free(&ifx_dev->tx_fifo); 833 834 } 834 835 ··· 863 862 dev_dbg(&ifx_dev->spi_dev->dev, 864 863 "%s: registering tty device failed", __func__); 865 864 ret = PTR_ERR(ifx_dev->tty_dev); 866 - goto error_ret; 865 + goto error_port; 867 866 } 868 867 return 0; 869 868 869 + error_port: 870 + tty_port_destroy(pport); 870 871 error_ret: 871 872 ifx_spi_free_port(ifx_dev); 872 873 return ret;
+2
drivers/tty/serial/kgdb_nmi.c
··· 266 266 } 267 267 return 0; 268 268 err: 269 + tty_port_destroy(&priv->port); 269 270 kfree(priv); 270 271 return ret; 271 272 } ··· 276 275 struct kgdb_nmi_tty_priv *priv = tty->driver_data; 277 276 278 277 tty->driver_data = NULL; 278 + tty_port_destroy(&priv->port); 279 279 kfree(priv); 280 280 } 281 281
+6
drivers/tty/serial/serial_core.c
··· 2297 2297 if (retval >= 0) 2298 2298 return retval; 2299 2299 2300 + for (i = 0; i < drv->nr; i++) 2301 + tty_port_destroy(&drv->state[i].port); 2300 2302 put_tty_driver(normal); 2301 2303 out_kfree: 2302 2304 kfree(drv->state); ··· 2318 2316 void uart_unregister_driver(struct uart_driver *drv) 2319 2317 { 2320 2318 struct tty_driver *p = drv->tty_driver; 2319 + unsigned int i; 2320 + 2321 2321 tty_unregister_driver(p); 2322 2322 put_tty_driver(p); 2323 + for (i = 0; i < drv->nr; i++) 2324 + tty_port_destroy(&drv->state[i].port); 2323 2325 kfree(drv->state); 2324 2326 drv->state = NULL; 2325 2327 drv->tty_driver = NULL;
+1
drivers/tty/synclink.c
··· 4425 4425 mgsl_release_resources(info); 4426 4426 tmp = info; 4427 4427 info = info->next_device; 4428 + tty_port_destroy(&tmp->port); 4428 4429 kfree(tmp); 4429 4430 } 4430 4431
+4 -1
drivers/tty/synclinkmp.c
··· 3843 3843 for ( port = 0; port < SCA_MAX_PORTS; ++port ) { 3844 3844 port_array[port] = alloc_dev(adapter_num,port,pdev); 3845 3845 if( port_array[port] == NULL ) { 3846 - for ( --port; port >= 0; --port ) 3846 + for (--port; port >= 0; --port) { 3847 + tty_port_destroy(&port_array[port]->port); 3847 3848 kfree(port_array[port]); 3849 + } 3848 3850 return; 3849 3851 } 3850 3852 } ··· 3955 3953 } 3956 3954 tmp = info; 3957 3955 info = info->next_device; 3956 + tty_port_destroy(&tmp->port); 3958 3957 kfree(tmp); 3959 3958 } 3960 3959
+4 -1
drivers/tty/vt/vt.c
··· 779 779 con_set_default_unimap(vc); 780 780 vc->vc_screenbuf = kmalloc(vc->vc_screenbuf_size, GFP_KERNEL); 781 781 if (!vc->vc_screenbuf) { 782 + tty_port_destroy(&vc->port); 782 783 kfree(vc); 783 784 vc_cons[currcons].d = NULL; 784 785 return -ENOMEM; ··· 1000 999 put_pid(vc->vt_pid); 1001 1000 module_put(vc->vc_sw->owner); 1002 1001 kfree(vc->vc_screenbuf); 1003 - if (currcons >= MIN_NR_CONSOLES) 1002 + if (currcons >= MIN_NR_CONSOLES) { 1003 + tty_port_destroy(&vc->port); 1004 1004 kfree(vc); 1005 + } 1005 1006 vc_cons[currcons].d = NULL; 1006 1007 } 1007 1008 }
+4 -1
drivers/usb/gadget/u_serial.c
··· 1145 1145 1146 1146 return status; 1147 1147 fail: 1148 - while (count--) 1148 + while (count--) { 1149 + tty_port_destroy(&ports[count].port->port); 1149 1150 kfree(ports[count].port); 1151 + } 1150 1152 put_tty_driver(gs_tty_driver); 1151 1153 gs_tty_driver = NULL; 1152 1154 return status; ··· 1202 1200 1203 1201 WARN_ON(port->port_usb != NULL); 1204 1202 1203 + tty_port_destroy(&port->port); 1205 1204 kfree(port); 1206 1205 } 1207 1206 n_ports = 0;
+1
drivers/usb/serial/usb-serial.c
··· 597 597 kfifo_free(&port->write_fifo); 598 598 kfree(port->interrupt_in_buffer); 599 599 kfree(port->interrupt_out_buffer); 600 + tty_port_destroy(&port->port); 600 601 kfree(port); 601 602 } 602 603
+1
net/irda/ircomm/ircomm_tty.c
··· 183 183 ircomm_tty_shutdown(self); 184 184 185 185 self->magic = 0; 186 + tty_port_destroy(&self->port); 186 187 kfree(self); 187 188 } 188 189