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 <dmytro_prokopch...@epam.com> --- Changes in v3: - inserted right Fixes tag, pointed by Andrew Cooper Link to v2: https://patchew.org/Xen/0e562f695e5db87ab80dde69cbcc0cfa14f94b21.1756373770.git.dmytro._5fprokopch...@epam.com/ --- 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; } -- 2.43.0