diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 0ab595e086c3..8af9efa0ca0a 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -702,7 +702,8 @@ int pstore_register(struct pstore_info *psi) return -EINVAL; } - allocate_buf_for_compression(); + if (psi->flags & PSTORE_FLAGS_DMESG) + allocate_buf_for_compression(); if (pstore_is_mounted()) pstore_get_records(0); diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 14f8bbd3ee01..40bfc6c58374 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -800,27 +800,37 @@ static int ramoops_probe(struct platform_device *pdev) goto fail_init_mprz; cxt->pstore.data = cxt; + /* + * Prepare frontend flags based on which areas are initialized. + * For ramoops_init_przs() cases, the "max count" variable tells + * if there are regions present. For ramoops_init_prz() cases, + * the single region size is how to check. + */ + cxt->pstore.flags = 0; + if (cxt->max_dump_cnt) + cxt->pstore.flags |= PSTORE_FLAGS_DMESG; + if (cxt->console_size) + cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE; + if (cxt->max_ftrace_cnt) + cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; + if (cxt->pmsg_size) + cxt->pstore.flags |= PSTORE_FLAGS_PMSG; + /* * Since bufsize is only used for dmesg crash dumps, it * must match the size of the dprz record (after PRZ header * and ECC bytes have been accounted for). */ - cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size; - cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL); - if (!cxt->pstore.buf) { - pr_err("cannot allocate pstore crash dump buffer\n"); - err = -ENOMEM; - goto fail_clear; + if (cxt->pstore.flags & PSTORE_FLAGS_DMESG) { + cxt->pstore.bufsize = cxt->dprzs[0]->buffer_size; + cxt->pstore.buf = kzalloc(cxt->pstore.bufsize, GFP_KERNEL); + if (!cxt->pstore.buf) { + pr_err("cannot allocate pstore crash dump buffer\n"); + err = -ENOMEM; + goto fail_clear; + } } - cxt->pstore.flags = PSTORE_FLAGS_DMESG; - if (cxt->console_size) - cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE; - if (cxt->ftrace_size) - cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; - if (cxt->pmsg_size) - cxt->pstore.flags |= PSTORE_FLAGS_PMSG; - err = pstore_register(&cxt->pstore); if (err) { pr_err("registering with pstore failed\n");