mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300()
@ 2024-01-31  8:24 Dan Carpenter
  2024-01-31  8:49 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-01-31  8:24 UTC (permalink / raw)
  To: Muralidhara M K
  Cc: Yazen Ghannam, Tony Luck, Borislav Petkov, linux-edac,
	linux-kernel, kernel-janitors

Check against ARRAY_SIZE() which is the number of elements instead of
sizeof() which is the number of bytes.  Otherwise we potentially read
beyond the end of the phy_to_log_coh_st_map_mi300[] array.

Fixes: 453f0ae79732 ("RAS/AMD/ATL: Add MI300 support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/ras/amd/atl/denormalize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ras/amd/atl/denormalize.c b/drivers/ras/amd/atl/denormalize.c
index d5d0e1fda159..49a900e066f1 100644
--- a/drivers/ras/amd/atl/denormalize.c
+++ b/drivers/ras/amd/atl/denormalize.c
@@ -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;
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-31  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31  8:24 [PATCH] RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300() Dan Carpenter
2024-01-31  8:49 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®