summary refs log tree commit diff stats
path: root/hw/ssi/aspeed_smc.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@redhat.com>2024-07-12 17:13:15 +0200
committerCédric Le Goater <clg@redhat.com>2024-07-21 07:46:38 +0200
commit13951ccfcdf0f31902a93859506ccf8c0ef66583 (patch)
tree6d56e4a109b1d559f59f84a202546dd6bd74b1c3 /hw/ssi/aspeed_smc.c
parenta87a7c449e532130d4fa8faa391ff7e1f04ed660 (diff)
downloadfocaccia-qemu-13951ccfcdf0f31902a93859506ccf8c0ef66583.tar.gz
focaccia-qemu-13951ccfcdf0f31902a93859506ccf8c0ef66583.zip
aspeed/smc: Fix possible integer overflow
Coverity reports a possible integer overflow because routine
aspeeed_smc_hclk_divisor() has a codepath returning 0, which could
lead to an integer overflow when computing variable 'hclk_shift' in
the caller aspeed_smc_dma_calibration().

The value passed to aspeed_smc_hclk_divisor() is always between 0 and
15 and, in this case, there is always a matching hclk divisor. Remove
the return 0 and use g_assert_not_reached() instead.

Fixes: Coverity CID 1547822
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/ssi/aspeed_smc.c')
-rw-r--r--hw/ssi/aspeed_smc.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 49205ab76d..f39fb85a35 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -789,8 +789,7 @@ static uint8_t aspeed_smc_hclk_divisor(uint8_t hclk_mask)
         }
     }
 
-    aspeed_smc_error("invalid HCLK mask %x", hclk_mask);
-    return 0;
+    g_assert_not_reached();
 }
 
 /*