Commit bda1b9ef authored by Brian Gerst's avatar Brian Gerst Committed by Linus Torvalds

[PATCH] mem leak in tty_io.c

The recent patch to clean up user accesses introduced a memory leak.  If
write_buf is reallocated, the old buffer isn't freed.  Also, since kfree
can take nulls, I removed the if from the other kfree.
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 79aac173
...@@ -168,8 +168,7 @@ static struct tty_struct *alloc_tty_struct(void) ...@@ -168,8 +168,7 @@ static struct tty_struct *alloc_tty_struct(void)
static inline void free_tty_struct(struct tty_struct *tty) static inline void free_tty_struct(struct tty_struct *tty)
{ {
if (tty->write_buf) kfree(tty->write_buf);
kfree(tty->write_buf);
kfree(tty); kfree(tty);
} }
...@@ -1060,6 +1059,7 @@ static inline ssize_t do_tty_write( ...@@ -1060,6 +1059,7 @@ static inline ssize_t do_tty_write(
up(&tty->atomic_write); up(&tty->atomic_write);
return -ENOMEM; return -ENOMEM;
} }
kfree(tty->write_buf);
tty->write_cnt = chunk; tty->write_cnt = chunk;
tty->write_buf = buf; tty->write_buf = buf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment