pstore: Avoid writing records with zero size

Sometimes pstore_console_write() will write records with zero size
to persistent ram zone, which is unnecessary. It will only increase
resource consumption. Also adjust ramoops_write_kmsg_hdr() to have
same logic if memory allocation fails.

Signed-off-by: Yue Hu <huyue2@yulong.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Yue Hu
2019-01-31 18:12:46 +08:00
committed by Kees Cook
parent 182ca6e0ae
commit 4c6c4d3453
2 changed files with 7 additions and 2 deletions

View File

@@ -501,6 +501,9 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
{
struct pstore_record record;
if (!c)
return;
pstore_record_init(&record, psinfo);
record.type = PSTORE_TYPE_CONSOLE;