]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.125/pstore-remove-needless-lock-during-console-writes.patch
Linux 4.14.125
[thirdparty/kernel/stable-queue.git] / releases / 4.14.125 / pstore-remove-needless-lock-during-console-writes.patch
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
5
6 From: Kees Cook <keescook@chromium.org>
7
8 commit b77fa617a2ff4d6beccad3d3d4b3a1f2d10368aa upstream.
9
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.
12
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>
17
18 ---
19 fs/pstore/platform.c | 29 ++++++-----------------------
20 1 file changed, 6 insertions(+), 23 deletions(-)
21
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)
27 {
28 - const char *e = s + c;
29 + struct pstore_record record;
30
31 - while (s < e) {
32 - struct pstore_record record;
33 - unsigned long flags;
34 + pstore_record_init(&record, psinfo);
35 + record.type = PSTORE_TYPE_CONSOLE;
36
37 - pstore_record_init(&record, psinfo);
38 - record.type = PSTORE_TYPE_CONSOLE;
39 -
40 - if (c > psinfo->bufsize)
41 - c = psinfo->bufsize;
42 -
43 - if (oops_in_progress) {
44 - if (!spin_trylock_irqsave(&psinfo->buf_lock, flags))
45 - break;
46 - } else {
47 - spin_lock_irqsave(&psinfo->buf_lock, flags);
48 - }
49 - record.buf = (char *)s;
50 - record.size = c;
51 - psinfo->write(&record);
52 - spin_unlock_irqrestore(&psinfo->buf_lock, flags);
53 - s += c;
54 - c = e - s;
55 - }
56 + record.buf = (char *)s;
57 + record.size = c;
58 + psinfo->write(&record);
59 }
60
61 static struct console pstore_console = {