diff options
-rw-r--r-- | kernel/printk/nmi.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/kernel/printk/nmi.c b/kernel/printk/nmi.c index b69eb8a2876f..16bab471c7e2 100644 --- a/kernel/printk/nmi.c +++ b/kernel/printk/nmi.c | |||
@@ -99,27 +99,33 @@ again: | |||
99 | return add; | 99 | return add; |
100 | } | 100 | } |
101 | 101 | ||
102 | /* | 102 | static void printk_nmi_flush_line(const char *text, int len) |
103 | * printk one line from the temporary buffer from @start index until | ||
104 | * and including the @end index. | ||
105 | */ | ||
106 | static void print_nmi_seq_line(struct nmi_seq_buf *s, int start, int end) | ||
107 | { | 103 | { |
108 | const char *buf = s->buffer + start; | ||
109 | |||
110 | /* | 104 | /* |
111 | * The buffers are flushed in NMI only on panic. The messages must | 105 | * The buffers are flushed in NMI only on panic. The messages must |
112 | * go only into the ring buffer at this stage. Consoles will get | 106 | * go only into the ring buffer at this stage. Consoles will get |
113 | * explicitly called later when a crashdump is not generated. | 107 | * explicitly called later when a crashdump is not generated. |
114 | */ | 108 | */ |
115 | if (in_nmi()) | 109 | if (in_nmi()) |
116 | printk_deferred("%.*s", (end - start) + 1, buf); | 110 | printk_deferred("%.*s", len, text); |
117 | else | 111 | else |
118 | printk("%.*s", (end - start) + 1, buf); | 112 | printk("%.*s", len, text); |
119 | 113 | ||
120 | } | 114 | } |
121 | 115 | ||
122 | /* | 116 | /* |
117 | * printk one line from the temporary buffer from @start index until | ||
118 | * and including the @end index. | ||
119 | */ | ||
120 | static void printk_nmi_flush_seq_line(struct nmi_seq_buf *s, | ||
121 | int start, int end) | ||
122 | { | ||
123 | const char *buf = s->buffer + start; | ||
124 | |||
125 | printk_nmi_flush_line(buf, (end - start) + 1); | ||
126 | } | ||
127 | |||
128 | /* | ||
123 | * Flush data from the associated per_CPU buffer. The function | 129 | * Flush data from the associated per_CPU buffer. The function |
124 | * can be called either via IRQ work or independently. | 130 | * can be called either via IRQ work or independently. |
125 | */ | 131 | */ |
@@ -150,9 +156,11 @@ more: | |||
150 | * the buffer an unexpected way. If we printed something then | 156 | * the buffer an unexpected way. If we printed something then |
151 | * @len must only increase. | 157 | * @len must only increase. |
152 | */ | 158 | */ |
153 | if (i && i >= len) | 159 | if (i && i >= len) { |
154 | pr_err("printk_nmi_flush: internal error: i=%d >= len=%zu\n", | 160 | const char *msg = "printk_nmi_flush: internal error\n"; |
155 | i, len); | 161 | |
162 | printk_nmi_flush_line(msg, strlen(msg)); | ||
163 | } | ||
156 | 164 | ||
157 | if (!len) | 165 | if (!len) |
158 | goto out; /* Someone else has already flushed the buffer. */ | 166 | goto out; /* Someone else has already flushed the buffer. */ |
@@ -166,14 +174,14 @@ more: | |||
166 | /* Print line by line. */ | 174 | /* Print line by line. */ |
167 | for (; i < size; i++) { | 175 | for (; i < size; i++) { |
168 | if (s->buffer[i] == '\n') { | 176 | if (s->buffer[i] == '\n') { |
169 | print_nmi_seq_line(s, last_i, i); | 177 | printk_nmi_flush_seq_line(s, last_i, i); |
170 | last_i = i + 1; | 178 | last_i = i + 1; |
171 | } | 179 | } |
172 | } | 180 | } |
173 | /* Check if there was a partial line. */ | 181 | /* Check if there was a partial line. */ |
174 | if (last_i < size) { | 182 | if (last_i < size) { |
175 | print_nmi_seq_line(s, last_i, size - 1); | 183 | printk_nmi_flush_seq_line(s, last_i, size - 1); |
176 | pr_cont("\n"); | 184 | printk_nmi_flush_line("\n", strlen("\n")); |
177 | } | 185 | } |
178 | 186 | ||
179 | /* | 187 | /* |