diff options
-rw-r--r-- | drivers/tty/tty_io.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 188632e4734d..026bf2f6f5f2 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -1391,16 +1391,15 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | |||
1391 | return ERR_PTR(-ENODEV); | 1391 | return ERR_PTR(-ENODEV); |
1392 | 1392 | ||
1393 | tty = alloc_tty_struct(); | 1393 | tty = alloc_tty_struct(); |
1394 | if (!tty) | 1394 | if (!tty) { |
1395 | goto fail_no_mem; | 1395 | retval = -ENOMEM; |
1396 | goto err_module_put; | ||
1397 | } | ||
1396 | initialize_tty_struct(tty, driver, idx); | 1398 | initialize_tty_struct(tty, driver, idx); |
1397 | 1399 | ||
1398 | retval = tty_driver_install_tty(driver, tty); | 1400 | retval = tty_driver_install_tty(driver, tty); |
1399 | if (retval < 0) { | 1401 | if (retval < 0) |
1400 | free_tty_struct(tty); | 1402 | goto err_free_tty; |
1401 | module_put(driver->owner); | ||
1402 | return ERR_PTR(retval); | ||
1403 | } | ||
1404 | 1403 | ||
1405 | /* | 1404 | /* |
1406 | * Structures all installed ... call the ldisc open routines. | 1405 | * Structures all installed ... call the ldisc open routines. |
@@ -1409,15 +1408,17 @@ struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, | |||
1409 | */ | 1408 | */ |
1410 | retval = tty_ldisc_setup(tty, tty->link); | 1409 | retval = tty_ldisc_setup(tty, tty->link); |
1411 | if (retval) | 1410 | if (retval) |
1412 | goto release_mem_out; | 1411 | goto err_release_tty; |
1413 | return tty; | 1412 | return tty; |
1414 | 1413 | ||
1415 | fail_no_mem: | 1414 | err_free_tty: |
1415 | free_tty_struct(tty); | ||
1416 | err_module_put: | ||
1416 | module_put(driver->owner); | 1417 | module_put(driver->owner); |
1417 | return ERR_PTR(-ENOMEM); | 1418 | return ERR_PTR(retval); |
1418 | 1419 | ||
1419 | /* call the tty release_tty routine to clean out this slot */ | 1420 | /* call the tty release_tty routine to clean out this slot */ |
1420 | release_mem_out: | 1421 | err_release_tty: |
1421 | if (printk_ratelimit()) | 1422 | if (printk_ratelimit()) |
1422 | printk(KERN_INFO "tty_init_dev: ldisc open failed, " | 1423 | printk(KERN_INFO "tty_init_dev: ldisc open failed, " |
1423 | "clearing slot %d\n", idx); | 1424 | "clearing slot %d\n", idx); |