diff options
-rw-r--r-- | drivers/tty/pty.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 210774726add..f5119184259c 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -295,8 +295,8 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | |||
295 | return -ENOMEM; | 295 | return -ENOMEM; |
296 | if (!try_module_get(driver->other->owner)) { | 296 | if (!try_module_get(driver->other->owner)) { |
297 | /* This cannot in fact currently happen */ | 297 | /* This cannot in fact currently happen */ |
298 | free_tty_struct(o_tty); | 298 | retval = -ENOMEM; |
299 | return -ENOMEM; | 299 | goto err_free_tty; |
300 | } | 300 | } |
301 | initialize_tty_struct(o_tty, driver->other, idx); | 301 | initialize_tty_struct(o_tty, driver->other, idx); |
302 | 302 | ||
@@ -304,13 +304,11 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | |||
304 | the easy way .. */ | 304 | the easy way .. */ |
305 | retval = tty_init_termios(tty); | 305 | retval = tty_init_termios(tty); |
306 | if (retval) | 306 | if (retval) |
307 | goto free_mem_out; | 307 | goto err_module_put; |
308 | 308 | ||
309 | retval = tty_init_termios(o_tty); | 309 | retval = tty_init_termios(o_tty); |
310 | if (retval) { | 310 | if (retval) |
311 | tty_free_termios(tty); | 311 | goto err_free_termios; |
312 | goto free_mem_out; | ||
313 | } | ||
314 | 312 | ||
315 | /* | 313 | /* |
316 | * Everything allocated ... set up the o_tty structure. | 314 | * Everything allocated ... set up the o_tty structure. |
@@ -327,10 +325,13 @@ static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | |||
327 | tty->count++; | 325 | tty->count++; |
328 | driver->ttys[idx] = tty; | 326 | driver->ttys[idx] = tty; |
329 | return 0; | 327 | return 0; |
330 | free_mem_out: | 328 | err_free_termios: |
329 | tty_free_termios(tty); | ||
330 | err_module_put: | ||
331 | module_put(o_tty->driver->owner); | 331 | module_put(o_tty->driver->owner); |
332 | err_free_tty: | ||
332 | free_tty_struct(o_tty); | 333 | free_tty_struct(o_tty); |
333 | return -ENOMEM; | 334 | return retval; |
334 | } | 335 | } |
335 | 336 | ||
336 | static int pty_bsd_ioctl(struct tty_struct *tty, | 337 | static int pty_bsd_ioctl(struct tty_struct *tty, |