[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] device-tree: fix infinite loop issue in 'assign_shared_memory()'


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Thu, 28 Aug 2025 09:39:40 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rC+z1m3Xqg9BGv69p4gUCcMrc5tPT/9elUP1cYDguXI=; b=Me0tKKBUYVKVKsKSQaey30pjfiuxm4XjtkWeOFKHq1ljBLoZCU8SfQHuBKWLB/FczXm0GV8/Of51CmumQpEqO97TpAyKyJIuB2/DEuZ7Vm5DasRGVe2Tt8eU2IsYk+7Y/nbiZ6t64c4U7zMbWUl5Lg2M+5oPtLuZKIouTswm2zXW9T9gx7yKx5gMzOmVyHs8nAA4fiioicJJJx0LzZO1plctILjcSxmzeZeaVFlURIA3SeYuLmJpvwxZEZu1N6Gn2Yd/FFpFhn/K6Kdx/gdN7lr1c04s4PfwZwxjBS4uYzJe4gwC+sqKT5nr8N+p+/L39O/wmPQhixlquFv2b62zrg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kk0cCSPTwqLbmS2Ft2j7oHCPUUsd9edHmdwFXWZCiUSHSxMdwpkXsfq+hIZm4JU6CcZ0R8hhYw6VYlh8+SEdxSC7FdmzngehQgH7p3Q/nEDHIqN+SYiEqs8piOUpiMqElDeL+Cg1inhkWrYzlphekCncBNHJJ5f/oHfNhj7wT6mXs1sWyM7ugKNsuYkyiAuK1O1IcCS6tU0BHzffgE3euem0sqki8N/9vXi9lzWBze4maJ/d+QD25l9Jrgn4FI/5fKckTC8EUQ+RfXtg4N+zxGOWgxXJBd8PFPer7l9Xu2ESg4N+2BIrH/jd9Ie+K4TMKYH85pAWZkQEi9ZYE3A37Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Thu, 28 Aug 2025 09:39:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcF/+t4SQcUfz6iUq+nv3WfuhiHA==
  • Thread-topic: [PATCH v2] 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: 72c5fa2208 (device-tree: Move Arm's static-shmem feature to common, 
2025-06-03)
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
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._5Fprokopchuk1@xxxxxxxx/
---
 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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.