Commit 784a9511 authored by Dan Carpenter's avatar Dan Carpenter Committed by PrithivishS
Browse files

RAS/AMD/ATL: Fix array overflow in get_logical_coh_st_fabric_id_mi300()

mainline inclusion
from mainline-v6.9-rc1
commit a7b57372e1c5c848cbe9169574f07a9ee2177a1b
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAYOV8
CVE: NA

Reference: https://github.com/torvalds/linux/commit/a7b57372e1c5c848cbe9169574f07a9ee2177a1b



--------------------------------

commit a7b57372e1c5c848cbe9169574f07a9ee2177a1b upstream.

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: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/279c8b5e-6c00-467a-9071-9c67926abea4@moroto.mountain


Signed-off-by: default avatarJeevan deep J <j.jeevandeep@amd.com>
Signed-off-by: default avatarPrithivishS <sprithiv@amd.com>
parent 685c23e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	}