linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RAS/AMD/FMPM: Fix off by one in error handling
@ 2024-03-06  5:30 Dan Carpenter
  2024-03-06  9:29 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-03-06  5:30 UTC (permalink / raw)
  To: Yazen Ghannam
  Cc: Yazen Ghannam, Tony Luck, Borislav Petkov,
	naveenkrishna.chatradhi, muralidhara.mk, linux-edac,
	linux-kernel, kernel-janitors

Decrement "i" before the first iteration.  Depending on where this fails
it could free something from one element beyond the end of the
fru_records[] array.

Fixes: 6f15e617cc99 ("RAS: Introduce a FRU memory poison manager")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/ras/amd/fmpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index 0963c9e7b853..2f4ac9591c8f 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -817,7 +817,7 @@ static int allocate_records(void)
 	return ret;
 
 out_free:
-	for (; i >= 0; i--)
+	while (--i >= 0)
 		kfree(fru_records[i]);
 
 	kfree(fru_records);
-- 
2.43.0


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

end of thread, other threads:[~2024-03-06  9:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-06  5:30 [PATCH] RAS/AMD/FMPM: Fix off by one in error handling Dan Carpenter
2024-03-06  9:29 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).