On 2025-08-28 11:39, Dmytro Prokopchuk1 wrote:
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: 72c5fa2208 (device-tree: Move Arm's static-shmem feature to common, 2025-06-03)

The format should be

Fixes: 72c5fa220804 ("device-tree: Move Arm's static-shmem feature to common")

can be fixed on commit probably

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopch...@epam.com>
---
Changes to v2:
- added Fixes tag
- updated the loop to use 'i--'
- updated commit message accordingly

Link to v1:
https://patchew.org/Xen/d7768394209c65cfef4006c3ffc0a0f5d82c4c18.1756368997.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;
 }

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253

Reply via email to