tty_audit: use kzalloc() in tty_audit_buf_alloc()
authorJiri Slaby <jirislaby@kernel.org>
Wed, 21 Jun 2023 10:16:07 +0000 (12:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Jun 2023 15:57:29 +0000 (17:57 +0200)
tty_audit_buf_alloc() manually erases most of the entries after
kmalloc(). So use kzalloc() and remove the manual sets to zero.

That way, we are sure that we do not omit anything.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230621101611.10580-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_audit.c

index b98b1aef5f6fd623f4b7e1e7d71490de0626337a..43f34465b9dfb4bfaccb02b64fc88d8363b8cf65 100644 (file)
@@ -33,16 +33,16 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void)
 {
        struct tty_audit_buf *buf;
 
-       buf = kmalloc(sizeof(*buf), GFP_KERNEL);
+       buf = kzalloc(sizeof(*buf), GFP_KERNEL);
        if (!buf)
                goto err;
+
        buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
        if (!buf->data)
                goto err_buf;
+
        mutex_init(&buf->mutex);
-       buf->dev = MKDEV(0, 0);
-       buf->icanon = 0;
-       buf->valid = 0;
+
        return buf;
 
 err_buf: