unsigned char *data;    /* Allocated size N_TTY_BUF_SIZE */
 };
 
+static struct tty_audit_buf *tty_audit_buf_ref(void)
+{
+       struct tty_audit_buf *buf;
+
+       buf = current->signal->tty_audit_buf;
+       WARN_ON(buf == ERR_PTR(-ESRCH));
+       return buf;
+}
+
 static struct tty_audit_buf *tty_audit_buf_alloc(void)
 {
        struct tty_audit_buf *buf;
 {
        struct tty_audit_buf *buf;
 
-       buf = current->signal->tty_audit_buf;
-       current->signal->tty_audit_buf = NULL;
+       buf = xchg(¤t->signal->tty_audit_buf, ERR_PTR(-ESRCH));
        if (!buf)
                return;
 
        if (~current->signal->audit_tty & AUDIT_TTY_ENABLE)
                return -EPERM;
 
-       buf = current->signal->tty_audit_buf;
-       if (buf) {
+       buf = tty_audit_buf_ref();
+       if (!IS_ERR_OR_NULL(buf)) {
                mutex_lock(&buf->mutex);
                tty_audit_buf_push(buf);
                mutex_unlock(&buf->mutex);
  *     tty_audit_buf_get       -       Get an audit buffer.
  *
  *     Get an audit buffer, allocate it if necessary.  Return %NULL
- *     if out of memory.  Otherwise, return a new reference to the buffer.
+ *     if out of memory or ERR_PTR(-ESRCH) if tty_audit_exit() has already
+ *     occurred.  Otherwise, return a new reference to the buffer.
  */
 static struct tty_audit_buf *tty_audit_buf_get(void)
 {
        struct tty_audit_buf *buf;
 
-       buf = current->signal->tty_audit_buf;
+       buf = tty_audit_buf_ref();
        if (buf)
                return buf;
 
        /* Race to use this buffer, free it if another wins */
        if (cmpxchg(¤t->signal->tty_audit_buf, NULL, buf) != NULL)
                tty_audit_buf_free(buf);
-       return current->signal->tty_audit_buf;
+       return tty_audit_buf_ref();
 }
 
 /**
                return;
 
        buf = tty_audit_buf_get();
-       if (!buf)
+       if (IS_ERR_OR_NULL(buf))
                return;
 
        mutex_lock(&buf->mutex);