diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 8741b57dbdc3..792735c08af7 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -444,6 +444,13 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size, vaddr = vmap(pages, page_count, VM_MAP | VM_IOREMAP, prot); kfree(pages); + /* + * vmap() may fail and return NULL. Do not add the offset in this + * case, otherwise a NULL mapping would appear successful. + */ + if (!vaddr) + return NULL; + /* * Since vmap() uses page granularity, we must add the offset * into the page here, to get the byte granularity address