Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338344
b: refs/heads/master
c: 70ece7a
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Oct 22, 2012
1 parent a9e18ba commit 009b6d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 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: 6c633f27ccf783e9a782b84e34aeaeb7949a3359
refs/heads/master: 70ece7a731598ac760c2a34421fcb2de18d2713f
19 changes: 18 additions & 1 deletion trunk/drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
#define ECHO_OP_SET_CANON_COL 0x81
#define ECHO_OP_ERASE_TAB 0x82

struct n_tty_data {
char dummy;
};

static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
unsigned char __user *ptr)
{
Expand Down Expand Up @@ -1556,11 +1560,15 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)

static void n_tty_close(struct tty_struct *tty)
{
struct n_tty_data *ldata = tty->disc_data;

n_tty_flush_buffer(tty);
kfree(tty->read_buf);
kfree(tty->echo_buf);
kfree(ldata);
tty->read_buf = NULL;
tty->echo_buf = NULL;
tty->disc_data = NULL;
}

/**
Expand All @@ -1575,23 +1583,32 @@ static void n_tty_close(struct tty_struct *tty)

static int n_tty_open(struct tty_struct *tty)
{
struct n_tty_data *ldata;

ldata = kzalloc(sizeof(*ldata), GFP_KERNEL);
if (!ldata)
goto err;

/* These are ugly. Currently a malloc failure here can panic */
tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
if (!tty->read_buf || !tty->echo_buf)
goto err_free_bufs;

tty->disc_data = ldata;
reset_buffer_flags(tty);
tty_unthrottle(tty);
tty->column = 0;
n_tty_set_termios(tty, NULL);
tty->minimum_to_wake = 1;
tty->closing = 0;

return 0;
err_free_bufs:
kfree(tty->read_buf);
kfree(tty->echo_buf);

kfree(ldata);
err:
return -ENOMEM;
}

Expand Down

0 comments on commit 009b6d1

Please sign in to comment.