ANDROID: arm64: Fix MMIO guard ioremap when called before slab_is_available().

The ioremap hook can be called before slab is initialised, at which time
calling into kmalloc() is not allowed.

Signed-off-by: Keir Fraser <keirf@google.com>
Bug: 232894028
Fixes: f89d2055a3 ("ANDROID: arm64: Implement ioremap/iounmap hooks calling into KVM's MMIO guard")
Change-Id: Ieaf5adbdacdb196e37f4629998164a015e15c6d8
This commit is contained in:
Keir Fraser
2022-05-17 07:52:53 +00:00
parent 65735b81dd
commit 0944dd4741

View File

@@ -108,7 +108,8 @@ void ioremap_phys_range_hook(phys_addr_t phys_addr, size_t size, pgprot_t prot)
* This page will be permanently accessible, similar to a
* saturated refcount.
*/
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
if (slab_is_available())
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
if (ref) {
refcount_set(&ref->count, 1);
if (xa_err(xa_store(&ioremap_guard_array, pfn, ref,