]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
hw/arm/smmuv3: Assert input to oas2bits() is valid
authorMostafa Saleh <smostafa@google.com>
Mon, 29 Jul 2024 12:34:18 +0000 (13:34 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 29 Jul 2024 12:34:18 +0000 (13:34 +0100)
Coverity has spotted a possible problem with the OAS handling
(CID 1558464), where the error return of oas2bits() -1 is not
checked, which can cause an overflow in oas value.

oas2bits() is only called with valid inputs, harden the function
to assert that.

Reported-By: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-id: 20240722103531.2377348-1-smostafa@google.com
Link: https://lore.kernel.org/qemu-devel/CAFEAcA-H=n-3mHC+eL6YjfL1m+x+b+Fk3mkgZbN74WNxifFVow@mail.gmail.com/
Signed-off-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/arm/smmuv3-internal.h

index 0ebf2eebcffb15523dc0b22e89f737fbb881b506..b6b7399347f22c290d8cb9c7f9cf0e62b057ad52 100644 (file)
@@ -599,7 +599,8 @@ static inline int oas2bits(int oas_field)
     case 5:
         return 48;
     }
-    return -1;
+
+    g_assert_not_reached();
 }
 
 /* CD fields */