Skip to content

Commit ec1132d

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: audit: do not use N_TTY_BUF_SIZE
N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size. There is no reason to couple that to audit's buffer size, so define an own TTY_AUDIT_BUF_SIZE macro (with the same size). N_TTY_BUF_SIZE is private and will be moved to n_tty.c later. Signed-off-by: Jiri Slaby (SUSE) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a72f418 commit ec1132d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/tty/tty_audit.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
#include <linux/tty.h>
1313
#include "tty.h"
1414

15+
#define TTY_AUDIT_BUF_SIZE 4096
16+
1517
struct tty_audit_buf {
1618
struct mutex mutex; /* Protects all data below */
1719
dev_t dev; /* The TTY which the data is from */
1820
bool icanon;
1921
size_t valid;
20-
u8 *data; /* Allocated size N_TTY_BUF_SIZE */
22+
u8 *data; /* Allocated size TTY_AUDIT_BUF_SIZE */
2123
};
2224

2325
static struct tty_audit_buf *tty_audit_buf_ref(void)
@@ -37,7 +39,7 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void)
3739
if (!buf)
3840
goto err;
3941

40-
buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
42+
buf->data = kmalloc(TTY_AUDIT_BUF_SIZE, GFP_KERNEL);
4143
if (!buf->data)
4244
goto err_buf;
4345

@@ -235,14 +237,14 @@ void tty_audit_add_data(const struct tty_struct *tty, const void *data,
235237
do {
236238
size_t run;
237239

238-
run = N_TTY_BUF_SIZE - buf->valid;
240+
run = TTY_AUDIT_BUF_SIZE - buf->valid;
239241
if (run > size)
240242
run = size;
241243
memcpy(buf->data + buf->valid, data, run);
242244
buf->valid += run;
243245
data += run;
244246
size -= run;
245-
if (buf->valid == N_TTY_BUF_SIZE)
247+
if (buf->valid == TTY_AUDIT_BUF_SIZE)
246248
tty_audit_buf_push(buf);
247249
} while (size != 0);
248250
mutex_unlock(&buf->mutex);

0 commit comments

Comments
 (0)