Commit 92499add authored by Yazen Ghannam's avatar Yazen Ghannam Committed by PrithivishS
Browse files

RAS/AMD/FMPM: Avoid NULL ptr deref in get_saved_records()

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

Reference: https://github.com/torvalds/linux/commit/4b0e527c9970a15ac9ec8fc44af957725b854c29



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

commit 4b0e527c9970a15ac9ec8fc44af957725b854c29 upstream

An old, invalid record should be cleared and skipped.

Currently, the record is cleared in ERST, but it is not skipped. This
leads to a NULL pointer dereference when attempting to copy the old
record to the new record.

Continue the loop after clearing an old, invalid record to skip it.

Fixes: 6f15e617cc99 ("RAS: Introduce a FRU memory poison manager")
Signed-off-by: default avatarYazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Tested-by: default avatarMuralidhara M K <muralidhara.mk@amd.com>
Link: https://lore.kernel.org/r/20240319113322.280096-2-yazen.ghannam@amd.com


Signed-off-by: default avatarsuryasaimadhu <SaiMadhu.KoyyalaHariVenkata@amd.com>
Signed-off-by: default avatarPrithivishS <sprithiv@amd.com>
parent d5054ed8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -676,8 +676,10 @@ static int get_saved_records(void)
		}

		new = get_valid_record(old);
		if (!new)
		if (!new) {
			erst_clear(record_id);
			continue;
		}

		/* Restore the record */
		memcpy(new, old, len);