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

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


  • To: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Thu, 28 Aug 2025 11:47:05 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1756374425; h=DKIM-Signature:MIME-Version:Date:From:To:Cc:Subject:In-Reply-To: References:Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=k8u/y/zcCwUh/VCOQj0590vl7KVi9uYN70b/lnDcouA=; b=tt1Aizn1Fy44XypiylC6+lamra05MfbzLL641oV+eSXEWbBaTf0iRslCrkrVzar8VFUe 9qu3VxDBjOJGB7tiFf3/GqjmRgPztu3dANqJR53lDCA1iLSOc+pj4n05aPYwteg82qNtc pzcMfDfwteFCRBe/cJocrnULBybRYmNisS5jpvUPQMZDIfmHlmoo++AwKeYw9VzgElfYc /92wU6mJe6PX3t5bkSx4xL+l0eLlwbhwFRfwIEtyr4WOC/sNRRtkuALuffDajt1Gt3XMU 7k4EeMStlD1kO8s5hpV0M8M56Qo3ES99xhGVu7rk+7J2Eignl6rIPIUOOzbHBy8H2cU+A AcjoaG+wNRxXjEkQUE//XpMmMp6dmzNw37P54XB1xH+fL97ETWXOVklEASPjhyOBAV8B4 d+NSY05rcv0C0+G/YCHAtzbNN84iQb8gTsbO8Em/WJQlbDSYLbtp1tP6T0KcQqTTkdGlh P9ad+PXj0t52oOfg9zQYGDvAHSRy8XE2QvEO2c4/p1ypqFjt9njoRmyg0CFda/+FEOqJd jpL644oA8dmUj+Y6Ie3xynRpxnEqkUJCClz5wpf07IGVnW5X0CFcZIkXybbnq4VX2fMFZ 48TTwJwFzFpgP/o6hNM3GSGabRWQSjQG5dMM8eJ+WjGFCJlCsdxLjDSFGKGXjsQ=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1756374425; b=Wk0VSLG0oladDHdTFGaNFJRuhH4/cDhTKkhK8006zxhvMN6fGnMeYQr0MLkNcDItqcdb 0doSXjlosZyWMrnhEURl9nmDMMbfzA7b5Ntv216QtTcLdlvGEIBnjZY3ki3Awj9+zmUI/ 7aJesBlIB9Zh+DGFFtS/uMLjxJ5X/KWlYcgew4QaL5owU9E/mIi6lx0DrRtsaf8nmI13F SWdP46iEznKokaxLeEJ/VgJL5Uqh69ZuLn9MXoCrwuqsquEHA7uupQ9LyXtNroXRWHTPY P/UdUgodWIlWE6xfzj0oXIqDGG9mB/4VfsjliUqLaSt7bPpGHwC0xFqa468GkryefzBHV VLVNS/fb1FvBujCbLKQ0Y/NT4B2LTNHGwAxuvgUjMrEH1+wJvSQQ0r+JS7pR0ecRBvWAW /vz9yR7BpqTpxqSRmqbt0p/Qw9fdCYdIJ5aMckWWHk2dv5iN/3q/2WeVMWDrzEvBaTZ9H zUisFN8EpVe36/pd0rZJIlfQ76n4WbIH3OUFzp2124+E7sWak8WRWI0/74YqqzWFlvL7n 1DRYB3Ff23+V7TaAAZRHbNGVJUw/DyxKTsxcljqewuxQHKznPIGeyhaxuBJhs6vz5USYR g7HuZvq0ytCyZg33gb3jL6ugCVU/NSmBjKyGY2T4zZ1jhytn3joTBekjgUqWgC0=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, 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:47:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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_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;
 }

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



 


Rackspace

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