summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2001-10-16 20:52:57 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2001-10-16 20:52:57 +0000
commit7307d94354642e2434dda59a2a736601970ccc7c (patch)
tree68f980c1c5aa3486f28a45b71d40f56dab5fc2a0
parent2001-10-10 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-7307d94354642e2434dda59a2a736601970ccc7c.tar.bz2
2001-10-11 Mike Siers <mikes@poliac.com>
* libc/termios.c: Fixed a memory leak in the termios software. Basically the tty open function was allocating an input raw buffer, an output raw buffer, and a cooked buffer that were not getting released. I have attached a patch for the latest snapshot. The patch also has a fix to ensure the tty link list is updated correctly when a tty is closed.
-rw-r--r--c/src/lib/libc/termios.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/c/src/lib/libc/termios.c b/c/src/lib/libc/termios.c
index 3dd122dca1..c23da7ab31 100644
--- a/c/src/lib/libc/termios.c
+++ b/c/src/lib/libc/termios.c
@@ -324,19 +324,30 @@ rtems_termios_close (void *arg)
drainOutput (tty);
if (tty->device.lastClose)
(*tty->device.lastClose)(tty->major, tty->minor, arg);
- if (tty->forw == NULL)
+ if (tty->forw == NULL) {
rtems_termios_ttyTail = tty->back;
- else
+ if ( rtems_termios_ttyTail != NULL ) {
+ rtems_termios_ttyTail->forw = NULL;
+ }
+ }
+ else {
tty->forw->back = tty->back;
- if (tty->back == NULL)
+ }
+ if (tty->back == NULL) {
rtems_termios_ttyHead = tty->forw;
- else
+ if ( rtems_termios_ttyHead != NULL ) {
+ rtems_termios_ttyHead->back = NULL;
+ }
+ }
+ else {
tty->back->forw = tty->forw;
+ }
rtems_semaphore_delete (tty->isem);
rtems_semaphore_delete (tty->osem);
rtems_semaphore_delete (tty->rawOutBufSemaphore);
if (!tty->device.pollRead)
rtems_semaphore_delete (tty->rawInBufSemaphore);
+ free (tty->cbuf);
free (tty);
}
rtems_semaphore_release (rtems_termios_ttyMutex);