1 From b77fa617a2ff4d6beccad3d3d4b3a1f2d10368aa Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Thu, 1 Nov 2018 14:08:07 -0700
4 Subject: pstore: Remove needless lock during console writes
6 From: Kees Cook <keescook@chromium.org>
8 commit b77fa617a2ff4d6beccad3d3d4b3a1f2d10368aa upstream.
10 Since the console writer does not use the preallocated crash dump buffer
11 any more, there is no reason to perform locking around it.
13 Fixes: 70ad35db3321 ("pstore: Convert console write to use ->write_buf")
14 Signed-off-by: Kees Cook <keescook@chromium.org>
15 Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 fs/pstore/platform.c | 29 ++++++-----------------------
20 1 file changed, 6 insertions(+), 23 deletions(-)
22 --- a/fs/pstore/platform.c
23 +++ b/fs/pstore/platform.c
24 @@ -597,31 +597,14 @@ static void pstore_unregister_kmsg(void)
25 #ifdef CONFIG_PSTORE_CONSOLE
26 static void pstore_console_write(struct console *con, const char *s, unsigned c)
28 - const char *e = s + c;
29 + struct pstore_record record;
32 - struct pstore_record record;
33 - unsigned long flags;
34 + pstore_record_init(&record, psinfo);
35 + record.type = PSTORE_TYPE_CONSOLE;
37 - pstore_record_init(&record, psinfo);
38 - record.type = PSTORE_TYPE_CONSOLE;
40 - if (c > psinfo->bufsize)
41 - c = psinfo->bufsize;
43 - if (oops_in_progress) {
44 - if (!spin_trylock_irqsave(&psinfo->buf_lock, flags))
47 - spin_lock_irqsave(&psinfo->buf_lock, flags);
49 - record.buf = (char *)s;
51 - psinfo->write(&record);
52 - spin_unlock_irqrestore(&psinfo->buf_lock, flags);
56 + record.buf = (char *)s;
58 + psinfo->write(&record);
61 static struct console pstore_console = {