From: Mostafa Saleh <smost...@google.com> 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.mayd...@linaro.org> Signed-off-by: Mostafa Saleh <smost...@google.com> Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org> Reviewed-by: Eric Auger <eric.au...@redhat.com> Message-id: 20240722103531.2377348-1-smost...@google.com Link: https://lore.kernel.org/qemu-devel/CAFEAcA-H=n-3mhc+el6yjfl1m+x+b+fk3mkgzbn74wnxiff...@mail.gmail.com/ Signed-off-by: Mostafa Saleh <smost...@google.com> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> --- hw/arm/smmuv3-internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index 0ebf2eebcff..b6b7399347f 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -599,7 +599,8 @@ static inline int oas2bits(int oas_field) case 5: return 48; } - return -1; + + g_assert_not_reached(); } /* CD fields */ -- 2.34.1