* [PATCH] efi: sanity check in case memermap() at efi_mem_reserve_persistent() returns NULL
@ 2019-11-13 20:56 Masayoshi Mizuma
0 siblings, 0 replies; only message in thread
From: Masayoshi Mizuma @ 2019-11-13 20:56 UTC (permalink / raw)
To: Ard Biesheuvel, linux-efi
Cc: Masayoshi Mizuma, Masayoshi Mizuma, linux-kernel, HATAYAMA Daisuke
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
System may crash as NULL pointer dereference in case memremap()
at efi_mem_reserve_persistent() returns NULL.
Add a sanity check to avoid that.
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reported-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
drivers/firmware/efi/efi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 07812d697..1d5ae7b95 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -1036,6 +1036,8 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
/* first try to find a slot in an existing linked list entry */
for (prsv = efi_memreserve_root->next; prsv; prsv = rsv->next) {
rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB);
+ if (!rsv)
+ return -ENOMEM;
index = atomic_fetch_add_unless(&rsv->count, 1, rsv->size);
if (index < rsv->size) {
rsv->entry[index].base = addr;
--
2.21.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-11-13 20:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-13 20:56 [PATCH] efi: sanity check in case memermap() at efi_mem_reserve_persistent() returns NULL Masayoshi Mizuma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®