aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mladek <[email protected]>2018-06-27 17:06:41 +0200
committerPetr Mladek <[email protected]>2018-07-09 13:38:03 +0200
commit8599dc7dec874b137384714bfe3ddbbf5d4a614e (patch)
treec1718cc72e21b75831dfbaf9efb86e8910f2ed79
parent63842c21347ecf4685d6ec008e667e61b0ead6e5 (diff)
printk: Clean up syslog_print_all()
syslog_print_all() is called twice. Once with a valid buffer and once just to set the indexes. Both variants are already handled separately. This patch just makes it more obvious. It does not change the existing behavior. Link: http://lkml.kernel.org/r/[email protected] Cc: Sergey Senozhatsky <[email protected]> Cc: Namit Gupta <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Petr Mladek <[email protected]>
-rw-r--r--kernel/printk/printk.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 16b02cc51a14..fcc1992c040a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1356,16 +1356,6 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
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;
@@ -1437,6 +1427,14 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
return len;
}
+static void syslog_clear(void)
+{
+ logbuf_lock_irq();
+ clear_seq = log_next_seq;
+ clear_idx = log_next_idx;
+ logbuf_unlock_irq();
+}
+
int do_syslog(int type, char __user *buf, int len, int source)
{
bool clear = false;
@@ -1481,7 +1479,7 @@ int do_syslog(int type, char __user *buf, int len, int source)
break;
/* Clear ring buffer */
case SYSLOG_ACTION_CLEAR:
- syslog_print_all(NULL, 0, true);
+ syslog_clear();
break;
/* Disable logging to console */
case SYSLOG_ACTION_CONSOLE_OFF: