lkml.org 
[lkml]   [2018]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] printk: remove unnecessary kmalloc() from syslog during clear
On (06/20/18 19:26), Namit Gupta wrote:
[..]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 512f7c2..53952ce 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1348,71 +1348,80 @@ 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;
> + }

---

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 4a07e7158898..33a1e45293a5 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1395,13 +1395,11 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
return 0;
}

-
text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
if (!text)
return -ENOMEM;

logbuf_lock_irq();
-
/*
* Find first record that fits, including all following records,
* into the user-provided buffer for this dump.
@@ -1436,7 +1434,7 @@ static int syslog_print_all(char __user *buf, int size, bool clear)
int textlen;

textlen = msg_print_text(msg, true, text,
- LOG_LINE_MAX + PREFIX_MAX);
+ LOG_LINE_MAX + PREFIX_MAX);
if (textlen < 0) {
len = textlen;
break;
---

Other than that, looks OK to me.

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

-ss

\
 
 \ /
  Last update: 2018-06-21 08:58    [W:0.081 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site