Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 113439
b: refs/heads/master
c: 6f967f7
h: refs/heads/master
i:
  113437: e4a0611
  113435: 4c2b1d8
  113431: 2794b12
  113423: acf7480
  113407: 305f80c
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Oct 13, 2008
1 parent ec55a07 commit 078fed6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9c9f4ded90a59eee84e15f5fd38c03d60184e112
refs/heads/master: 6f967f7891076abc09e12ce952f85825e7ee8caf
17 changes: 11 additions & 6 deletions trunk/drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,12 @@ static int init_dev(struct tty_driver *driver, int idx,
o_tty = alloc_tty_struct();
if (!o_tty)
goto free_mem_out;
if (!try_module_get(driver->other->owner)) {
/* This cannot in fact currently happen */
free_tty_struct(o_tty);
o_tty = NULL;
goto free_mem_out;
}
initialize_tty_struct(o_tty);
o_tty->driver = driver->other;
o_tty->ops = driver->ops;
Expand Down Expand Up @@ -1411,8 +1417,10 @@ static int init_dev(struct tty_driver *driver, int idx,
/* Release locally allocated memory ... nothing placed in slots */
free_mem_out:
kfree(o_tp);
if (o_tty)
if (o_tty) {
module_put(o_tty->driver->owner);
free_tty_struct(o_tty);
}
kfree(ltp);
kfree(tp);
free_tty_struct(tty);
Expand Down Expand Up @@ -1447,6 +1455,7 @@ static int init_dev(struct tty_driver *driver, int idx,
static void release_one_tty(struct kref *kref)
{
struct tty_struct *tty = container_of(kref, struct tty_struct, kref);
struct tty_driver *driver = tty->driver;
int devpts = tty->driver->flags & TTY_DRIVER_DEVPTS_MEM;
struct ktermios *tp;
int idx = tty->index;
Expand All @@ -1471,6 +1480,7 @@ static void release_one_tty(struct kref *kref)
tty->magic = 0;
/* FIXME: locking on tty->driver->refcount */
tty->driver->refcount--;
module_put(driver->owner);

file_list_lock();
list_del_init(&tty->tty_files);
Expand Down Expand Up @@ -1506,20 +1516,15 @@ EXPORT_SYMBOL(tty_kref_put);
* of ttys that the driver keeps.
* FIXME: should we require tty_mutex is held here ??
*
* FIXME: We want to defer the module put of the driver to the
* destructor.
*/
static void release_tty(struct tty_struct *tty, int idx)
{
struct tty_driver *driver = tty->driver;

/* This should always be true but check for the moment */
WARN_ON(tty->index != idx);

if (tty->link)
tty_kref_put(tty->link);
tty_kref_put(tty);
module_put(driver->owner);
}

/*
Expand Down

0 comments on commit 078fed6

Please sign in to comment.