]> Git Repo - J-linux.git/blobdiff - drivers/tty/tty_buffer.c
Merge branch 'parisc-4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[J-linux.git] / drivers / tty / tty_buffer.c
index c996b6859c5e70c72827f28c33c46bd3d96a1cda..77070c2d1240421fa34f48db9a2ddb24a961f2f0 100644 (file)
@@ -118,9 +118,12 @@ void tty_buffer_free_all(struct tty_port *port)
        struct tty_bufhead *buf = &port->buf;
        struct tty_buffer *p, *next;
        struct llist_node *llist;
+       unsigned int freed = 0;
+       int still_used;
 
        while ((p = buf->head) != NULL) {
                buf->head = p->next;
+               freed += p->size;
                if (p->size > 0)
                        kfree(p);
        }
@@ -132,7 +135,9 @@ void tty_buffer_free_all(struct tty_port *port)
        buf->head = &buf->sentinel;
        buf->tail = &buf->sentinel;
 
-       atomic_set(&buf->mem_used, 0);
+       still_used = atomic_xchg(&buf->mem_used, 0);
+       WARN(still_used != freed, "we still have not freed %d bytes!",
+                       still_used - freed);
 }
 
 /**
@@ -468,11 +473,15 @@ receive_buf(struct tty_port *port, struct tty_buffer *head, int count)
 {
        unsigned char *p = char_buf_ptr(head, head->read);
        char          *f = NULL;
+       int n;
 
        if (~head->flags & TTYB_NORMAL)
                f = flag_buf_ptr(head, head->read);
 
-       return port->client_ops->receive_buf(port, p, f, count);
+       n = port->client_ops->receive_buf(port, p, f, count);
+       if (n > 0)
+               memset(p, 0, n);
+       return n;
 }
 
 /**
This page took 0.028401 seconds and 4 git commands to generate.