Skip to content

Commit 38b9184

Browse files
guilhermepiccolikees
authored andcommitted
pstore: Alert on backend write error
The pstore dump function doesn't alert at all on errors - despite pstore is usually a last resource and if it fails users won't be able to read the kernel log, this is not the case for server users with serial access, for example. So, let's at least attempt to inform such advanced users on the first backend writing error detected during the kmsg dump - this is also very useful for pstore debugging purposes. Signed-off-by: Guilherme G. Piccoli <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7d7eca4 commit 38b9184

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/pstore/platform.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
393393
const char *why;
394394
unsigned int part = 1;
395395
unsigned long flags = 0;
396+
int saved_ret = 0;
396397
int ret;
397398

398399
why = kmsg_dump_reason_str(reason);
@@ -463,12 +464,21 @@ static void pstore_dump(struct kmsg_dumper *dumper,
463464
if (ret == 0 && reason == KMSG_DUMP_OOPS) {
464465
pstore_new_entry = 1;
465466
pstore_timer_kick();
467+
} else {
468+
/* Preserve only the first non-zero returned value. */
469+
if (!saved_ret)
470+
saved_ret = ret;
466471
}
467472

468473
total += record.size;
469474
part++;
470475
}
471476
spin_unlock_irqrestore(&psinfo->buf_lock, flags);
477+
478+
if (saved_ret) {
479+
pr_err_once("backend (%s) writing error (%d)\n", psinfo->name,
480+
saved_ret);
481+
}
472482
}
473483

474484
static struct kmsg_dumper pstore_dumper = {

0 commit comments

Comments
 (0)