printk: Remove unnecessary kmalloc() from syslog during clear

When the request is only for clearing logs, there is no need for
allocation/deallocation. Only the indexes need to be reset and returned.
Rest of the patch is mostly made up of changes because of indention.

Link: http://lkml.kernel.org/r/20180620135951epcas5p3bd2a8f25ec689ca333bce861b527dba2~54wyKcT0_3155531555epcas5p3y@epcas5p3.samsung.com
Cc: linux-kernel@vger.kernel.org
Cc: pankaj.m@samsung.com
Cc: a.sahrawat@samsung.com
Signed-off-by: Namit Gupta <gupta.namit@samsung.com>
Signed-off-by: Himanshu Maithani <himanshu.m@samsung.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
This commit is contained in:
Namit Gupta 2018-06-20 19:26:19 +05:30 committed by Petr Mladek
parent 22eceb8bf3
commit 63842c2134

View File

@ -1352,17 +1352,25 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
{
char *text;
int len = 0;
u64 next_seq;
u64 seq;
u32 idx;
if (!buf) {
if (clear) {
logbuf_lock_irq();
clear_seq = log_next_seq;
clear_idx = log_next_idx;
logbuf_unlock_irq();
}
return 0;
}
text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
if (!text)
return -ENOMEM;
logbuf_lock_irq();
if (buf) {
u64 next_seq;
u64 seq;
u32 idx;
/*
* Find first record that fits, including all following records,
* into the user-provided buffer for this dump.
@ -1418,7 +1426,6 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
idx = log_first_idx;
}
}
}
if (clear) {
clear_seq = log_next_seq;