linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mem leak in tty_io.c
@ 2004-10-24  2:58 Brian Gerst
  0 siblings, 0 replies; only message in thread
From: Brian Gerst @ 2004-10-24  2:58 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml

[-- Attachment #1: Type: text/plain, Size: 223 bytes --]

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.

--
				Brian Gerst

[-- Attachment #2: tty-kfree --]
[-- Type: text/plain, Size: 554 bytes --]

diff -urN linux-2.6.9-bk/drivers/char/tty_io.c linux/drivers/char/tty_io.c
--- linux-2.6.9-bk/drivers/char/tty_io.c	2004-10-22 09:53:21.373263820 -0400
+++ linux/drivers/char/tty_io.c	2004-10-22 10:36:10.753679871 -0400
@@ -168,8 +168,7 @@
 
 static inline void free_tty_struct(struct tty_struct *tty)
 {
-	if (tty->write_buf)
-		kfree(tty->write_buf);
+	kfree(tty->write_buf);
 	kfree(tty);
 }
 
@@ -1060,6 +1059,7 @@
 			up(&tty->atomic_write);
 			return -ENOMEM;
 		}
+		kfree(tty->write_buf);
 		tty->write_cnt = chunk;
 		tty->write_buf = buf;
 	}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-10-24  2:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-24  2:58 [PATCH] mem leak in tty_io.c Brian Gerst

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).