RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 31 Jan 2024 08:24:25 +0000 (11:24 +0300)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 31 Jan 2024 08:44:06 +0000 (09:44 +0100)
Check against ARRAY_SIZE() which is the number of elements instead of
sizeof() which is the number of bytes.

Fixes: 453f0ae79732 ("RAS/AMD/ATL: Add MI300 support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/279c8b5e-6c00-467a-9071-9c67926abea4@moroto.mountain
drivers/ras/amd/atl/denormalize.c

index d5d0e1fda15908ad730b417af230da1d200a8e83..49a900e066f1343f13bf310d28308c41cd9aa26e 100644 (file)
@@ -405,7 +405,7 @@ static const u16 phy_to_log_coh_st_map_mi300[] = {
 
 static u16 get_logical_coh_st_fabric_id_mi300(struct addr_ctx *ctx)
 {
-       if (ctx->inst_id >= sizeof(phy_to_log_coh_st_map_mi300)) {
+       if (ctx->inst_id >= ARRAY_SIZE(phy_to_log_coh_st_map_mi300)) {
                atl_debug(ctx, "Instance ID out of range");
                return ~0;
        }