[vmbase] Adjust only the refill layout in memory allocation

As a follow-up of the cl aosp/2660016.

Bug: 274441673
Test: atest MicrodroidTests
Change-Id: Ie076838ad5b42c36ca1ca4bb38cf6fe1ccd35566
diff --git a/vmbase/src/memory/shared.rs b/vmbase/src/memory/shared.rs
index 68f9ebd..064fb6d 100644
--- a/vmbase/src/memory/shared.rs
+++ b/vmbase/src/memory/shared.rs
@@ -355,17 +355,16 @@
 }
 
 fn try_shared_alloc(layout: Layout) -> Option<NonNull<u8>> {
-    // Adjusts the layout size to the max of the next power of two and the alignment,
-    // as this is the actual size of the memory allocated in `alloc_aligned()`.
-    let size = max(layout.size().next_power_of_two(), layout.align());
-    let layout = Layout::from_size_align(size, layout.align()).unwrap();
-
     let mut shared_pool = SHARED_POOL.get().unwrap().lock();
 
     if let Some(buffer) = shared_pool.alloc_aligned(layout) {
         Some(NonNull::new(buffer as _).unwrap())
     } else if let Some(shared_memory) = SHARED_MEMORY.lock().as_mut() {
-        shared_memory.refill(&mut shared_pool, layout);
+        // Adjusts the layout size to the max of the next power of two and the alignment,
+        // as this is the actual size of the memory allocated in `alloc_aligned()`.
+        let size = max(layout.size().next_power_of_two(), layout.align());
+        let refill_layout = Layout::from_size_align(size, layout.align()).unwrap();
+        shared_memory.refill(&mut shared_pool, refill_layout);
         shared_pool.alloc_aligned(layout).map(|buffer| NonNull::new(buffer as _).unwrap())
     } else {
         None