Commit bd08ec33b5c23833581e5a36b2a69ccae6b39a28

Authored by Arve Hjønnevåg
Committed by Anton Vorontsov
1 parent c31ad081e8

pstore/ram: Restore ecc information block

This was lost when proc/last_kmsg moved to pstore/console-ramoops.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>

Showing 2 changed files with 13 additions and 2 deletions Side-by-side Diff

... ... @@ -136,6 +136,7 @@
136 136 char **buf, struct pstore_info *psi)
137 137 {
138 138 ssize_t size;
  139 + ssize_t ecc_notice_size;
139 140 struct ramoops_context *cxt = psi->data;
140 141 struct persistent_ram_zone *prz;
141 142  
142 143  
... ... @@ -156,11 +157,18 @@
156 157 time->tv_nsec = 0;
157 158  
158 159 size = persistent_ram_old_size(prz);
159   - *buf = kmemdup(persistent_ram_old(prz), size, GFP_KERNEL);
  160 +
  161 + /* ECC correction notice */
  162 + ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0);
  163 +
  164 + *buf = kmalloc(size + ecc_notice_size + 1, GFP_KERNEL);
160 165 if (*buf == NULL)
161 166 return -ENOMEM;
162 167  
163   - return size;
  168 + memcpy(*buf, persistent_ram_old(prz), size);
  169 + persistent_ram_ecc_string(prz, *buf + size, ecc_notice_size + 1);
  170 +
  171 + return size + ecc_notice_size;
164 172 }
165 173  
166 174 static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz)
fs/pstore/ram_core.c
... ... @@ -235,6 +235,9 @@
235 235 {
236 236 ssize_t ret;
237 237  
  238 + if (!prz->ecc_info.ecc_size)
  239 + return 0;
  240 +
238 241 if (prz->corrected_bytes || prz->bad_blocks)
239 242 ret = snprintf(str, len, ""
240 243 "\n%d Corrected bytes, %d unrecoverable blocks\n",