Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146271
b: refs/heads/master
c: 0b4068a
h: refs/heads/master
i:
  146269: 4d823b0
  146267: e532c13
  146263: ba0fd8e
  146255: bdb620c
  146239: 9a6ab26
v: v3
  • Loading branch information
Alan Cox authored and Linus Torvalds committed Jun 11, 2009
1 parent d1a1443 commit 9161bea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 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: c481c707fe4b07783d9a2499a9bbbb94497e9b18
refs/heads/master: 0b4068a1287b02018d1b3159e7be6f27f3e3e68c
22 changes: 5 additions & 17 deletions trunk/drivers/char/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@
#define ECHO_OP_SET_CANON_COL 0x81
#define ECHO_OP_ERASE_TAB 0x82

static inline unsigned char *alloc_buf(void)
{
gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
return kmalloc(N_TTY_BUF_SIZE, prio);
}

static inline void free_buf(unsigned char *buf)
{
kfree(buf);
}

static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
unsigned char __user *ptr)
{
Expand Down Expand Up @@ -1551,11 +1540,11 @@ static void n_tty_close(struct tty_struct *tty)
{
n_tty_flush_buffer(tty);
if (tty->read_buf) {
free_buf(tty->read_buf);
kfree(tty->read_buf);
tty->read_buf = NULL;
}
if (tty->echo_buf) {
free_buf(tty->echo_buf);
kfree(tty->echo_buf);
tty->echo_buf = NULL;
}
}
Expand All @@ -1577,17 +1566,16 @@ static int n_tty_open(struct tty_struct *tty)

/* These are ugly. Currently a malloc failure here can panic */
if (!tty->read_buf) {
tty->read_buf = alloc_buf();
tty->read_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
if (!tty->read_buf)
return -ENOMEM;
}
if (!tty->echo_buf) {
tty->echo_buf = alloc_buf();
tty->echo_buf = kzalloc(N_TTY_BUF_SIZE, GFP_KERNEL);

if (!tty->echo_buf)
return -ENOMEM;
}
memset(tty->read_buf, 0, N_TTY_BUF_SIZE);
memset(tty->echo_buf, 0, N_TTY_BUF_SIZE);
reset_buffer_flags(tty);
tty->column = 0;
n_tty_set_termios(tty, NULL);
Expand Down

0 comments on commit 9161bea

Please sign in to comment.