Re: [PATCH v3 3/7] cper: add helpers to handle Memory Error Section 2

From: Pierre Gondois

Date: Mon Nov 09 2026 - 05:57:21 EST



On 11/4/26 18:25, Mark Brown wrote:
On Wed, Nov 04, 2026 at 12:03:11PM +0100, Pierre Gondois wrote:
Add separate location and printing helpers for Memory Error
Section 2:
- cper_mem_err2_location()
- cper_dimm_err2_location()
- cper_print_mem2()
+int cper_dimm_err2_location(const struct cper_sec_mem_err2 *mem, char *msg)
+{
+ u32 len, n;
+ const char *bank = NULL, *device = NULL;
+
+ if (!msg || !(mem->validation_bits & CPER_MEM2_VALID_MODULE_HANDLE))
+ return 0;
+
+ /* SMBIOS handles are 16 bits; never truncate a Section 2 handle. */
+ if (mem->mem_dev_handle <= U16_MAX)
+ dmi_memdev_name(mem->mem_dev_handle, &bank, &device);
+ else
+ pr_warn(FW_WARN "Memory Error Section 2 module handle 0x%x exceeds SMBIOS range\n",
+ mem->mem_dev_handle);
Should this be rate limited?

+ len = CPER_REC_LEN;
+ if (bank && device)
+ n = snprintf(msg, len, "DIMM location: %s %s ", bank, device);
+ else
+ n = snprintf(msg, len,
+ "DIMM location: not present. DMI handle: 0x%.8x ",
+ mem->mem_dev_handle);
Shouldn't this be scnprintf(), especially in the first case where the
strings come from the firmware?

Right, I ll update cper_dimm_err_location() aswell.