From 30f5b19f41ee4c5e639ef49878c63e99bc5f6ce5 Mon Sep 17 00:00:00 2001 From: Dmytro Prokopchuk1 Date: Mon, 1 Sep 2025 09:26:45 +0000 Subject: [PATCH] device-tree: fix infinite loop issue in 'assign_shared_memory()' Fix an issue in the 'fail:' cleanup path of the 'assign_shared_memory()' function where the use of an unsigned long 'i' with the condition '--i >= 0' caused an infinite loop. Update the loop to use 'i--', ensuring correct loop termination. This change adheres to MISRA C Rule 14.3: "Controlling expressions shall not be invariant." Fixes: 041957bad382 ("xen/arm: Add additional reference to owner domain when the owner is allocated") Signed-off-by: Dmytro Prokopchuk Acked-by: Michal Orzel --- xen/common/device-tree/static-shmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/common/device-tree/static-shmem.c b/xen/common/device-tree/static-shmem.c index 8023c0a484..79f23caa77 100644 --- a/xen/common/device-tree/static-shmem.c +++ b/xen/common/device-tree/static-shmem.c @@ -185,7 +185,7 @@ static int __init assign_shared_memory(struct domain *d, paddr_t gbase, return 0; fail: - while ( --i >= 0 ) + while ( i-- ) put_page_nr(page + i, nr_borrowers); return ret; }