[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] 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 08:17: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=FjoIr7lFyfFpDbEr/04MtKkgMC5IM9Adq0/W0rKKUFE=; b=v/ZkOI+Mt9JYUPSe5C1ETYDOuofxVA7Wy569Q+GQup6r7GlSJJQuqaP0YVODpxxEi+dzBmE0o11maTWYKOlJgRsFIKoGeUTMw7G5dd8jcSFs7EAW5oSjywP3nAhJsnQxnjX+EXtGcxoYoWHPK3kZLlTUAWrFeN5yjPcTlPuCxZY8i9BUbbmpzeZr/VjoXGcJteRIbzD6foHvh/RtXVEul7WBZa0FZffrgzZ+hsLyiZuVfspu5jyaLGNa3QaiZuxiJR71rqsSil3MOCVhpmiWnbCiHUO1d4URpc2OIRy7xxsYkVzRpXlEgcu/3HnkVjryaFvvYKfNmre/xm/y+obegg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yMECBYxrXNebxk3ni77NJ+V+jYvnwUbOa1yn1JhwKHmThV8wIGs3WSqxLI/QilN6nROt0a/3+sAQfqBHKA+bonTlYTB60qewLkgDdkDLsQZx3aRLTb2GBXBCytFejJPTlo9NKW5dG7DQbTkhAs/W0E2PT21fZNnx6t9NFHtdDljIZAgN3J5ClsZKwu92kC9BXSukKl5ZdaKThLadgRDWjL1OTuhNtwtSG7O/2PeBFVavkk9Dq3t3zL7J9iJM8+kXKpyWp+BE29tCywf2kYN4VHvqu0PfSEhMiv4vR9IaxLXo3LLrQz5JdMRWqWJPNq3TPb2kkQbZEdJcTi1VPhHvug==
- 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 08:17:58 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcF/Q482rbLahQD0qhywmRaenDcQ==
- Thread-topic: [PATCH] device-tree: fix infinite loop issue in 'assign_shared_memory()'
Resolve infinite loop issue in the 'fail:' cleanup path of the function
'assign_shared_memory()'. The issue was caused by an 'unsigned long' type
for the loop counter 'i', which could underflow and wrap around, violating
termination conditions.
Change 'i' to a signed data type ('long') to ensure safe termination of
the 'while (--i >= 0)' loop.
This change adheres to MISRA Rule R14.3: "Controlling expressions shall
not be invariant."
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
xen/common/device-tree/static-shmem.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xen/common/device-tree/static-shmem.c
b/xen/common/device-tree/static-shmem.c
index 8023c0a484..b4c772466c 100644
--- a/xen/common/device-tree/static-shmem.c
+++ b/xen/common/device-tree/static-shmem.c
@@ -134,7 +134,8 @@ static int __init assign_shared_memory(struct domain *d,
paddr_t gbase,
{
mfn_t smfn;
int ret = 0;
- unsigned long nr_pages, nr_borrowers, i;
+ unsigned long nr_pages, nr_borrowers;
+ long i;
struct page_info *page;
paddr_t pbase, psize;
--
2.43.0
|