Commit bd17b7c3 authored by Dan Carpenter's avatar Dan Carpenter Committed by Borislav Petkov (AMD)

RAS/AMD/FMPM: Fix off by one when unwinding on error

Decrement the index variable i before the first iteration when freeing
the remaining elements on error. Depending on where this fails it could
free something from one element beyond the end of the fru_records[]
array.

  [ bp: Massage commit message. ]

Fixes: 6f15e617 ("RAS: Introduce a FRU memory poison manager")
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/6fdec71a-846b-4cd0-af69-e5f6cd12f4f6@moroto.mountain
parent 7d19eea5
...@@ -817,7 +817,7 @@ static int allocate_records(void) ...@@ -817,7 +817,7 @@ static int allocate_records(void)
return ret; return ret;
out_free: out_free:
for (; i >= 0; i--) while (--i >= 0)
kfree(fru_records[i]); kfree(fru_records[i]);
kfree(fru_records); kfree(fru_records);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment