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

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

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

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



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

commit bd17b7c34fadef645becde1245b9394f69f31702 upstream

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: 6f15e617cc99 ("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


Signed-off-by: default avatarsuryasaimadhu <SaiMadhu.KoyyalaHariVenkata@amd.com>
Signed-off-by: default avatarPrithivishS <sprithiv@amd.com>
parent d649c000
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);