From e299aa7e30ea7227c4bcb06d48c07745a82291b2 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 30 Oct 2020 15:36:19 +0100 Subject: [PATCH 2/3] dmidecode: Skip details of uninstalled memory modules If a memory slot is empty then by definition the fields containing the memory module details are irrelevant. Best case they are filled with "Unused" and "None", but in some cases they are even invalid because the manufacturer did not bother setting the fields to valid neutral values. So it is better to not print these fields at all, so as to not confuse the user. Signed-off-by: Jean Delvare --- dmidecode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dmidecode.c b/dmidecode.c index 7da2b12e3b98..eca7d15863b2 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -4387,6 +4387,9 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) dmi_memory_device_type_detail(WORD(data + 0x13)); printf("\n"); if (h->length < 0x17) break; + /* If no module is present, the remaining fields are irrelevant */ + if (WORD(data + 0x0C) == 0) + break; printf("\tSpeed:"); dmi_memory_device_speed(WORD(data + 0x15)); printf("\n"); -- 2.17.1