Skip to content

Commit bd17b7c

Browse files
Dan Carpenterbp3tk0v
authored andcommitted
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: 6f15e61 ("RAS: Introduce a FRU memory poison manager") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/6fdec71a-846b-4cd0-af69-e5f6cd12f4f6@moroto.mountain
1 parent 7d19eea commit bd17b7c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/ras/amd/fmpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ static int allocate_records(void)
817817
return ret;
818818

819819
out_free:
820-
for (; i >= 0; i--)
820+
while (--i >= 0)
821821
kfree(fru_records[i]);
822822

823823
kfree(fru_records);

0 commit comments

Comments
 (0)