From 354fa5d5bf9035d7c426482bd29e0f831ec11e37 Mon Sep 17 00:00:00 2001 From: Peng Yang Date: Tue, 15 Jul 2025 23:49:43 -0700 Subject: [PATCH] ANDROID: gunyah: GKI: Avoid release the CMA memory when it's in use One process boots up SVM, the CMA memory is allocated and used by SVM. If another process try to boot up VM again, will allocate fail and release this CMA memory region. It will cause kernel panic when one process allocates memory from this CMA memory region due to not do relciam parcel for this memory. Fix this issue by return a error in gunyah_cma_create_mem_fd to avoid gunyah_cma_release is called when the CMA memory region is already allocated by other process. Bug: 432359620 Change-Id: Iee2d20d455e80d992db45c875488fd9cb631f8fd Signed-off-by: Peng Yang --- drivers/virt/gunyah/vm_mgr_cma_mem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virt/gunyah/vm_mgr_cma_mem.c b/drivers/virt/gunyah/vm_mgr_cma_mem.c index 07ffe49c6287..c5f91852fc52 100644 --- a/drivers/virt/gunyah/vm_mgr_cma_mem.c +++ b/drivers/virt/gunyah/vm_mgr_cma_mem.c @@ -257,6 +257,9 @@ static long gunyah_cma_create_mem_fd(struct gunyah_cma *cma) struct file *file; int fd, err; + if (cma->page) + return -EBUSY; + flags |= O_CLOEXEC; fd = get_unused_fd_flags(flags); if (fd < 0)