Skip to content

Commit

Permalink
RAS/AMD/FMPM: Fix off by one when unwinding on error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Dan Carpenter authored and Borislav Petkov (AMD) committed Mar 6, 2024
1 parent 7d19eea commit bd17b7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/ras/amd/fmpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bd17b7c

Please sign in to comment.