lshw/0001-Fix-getting-size-of-memory-banks-32GiB.patch

45 lines
1.9 KiB
Diff
Raw Normal View History

From 74e23540335254b8fca6a81cc891c52d96937d40 Mon Sep 17 00:00:00 2001
From: Lyonel Vincent <lyonel@ezix.org>
Date: Thu, 29 Apr 2021 16:40:37 +0200
Subject: [PATCH] Fix getting size of memory banks <32GiB
PR65 on Github (thanks to Z.Bitter)
Due to a regression introduced by 8ff1efb, no size was recorded for memory banks <32GiB in size on systems with an SMBIOS version of 2.7 or later. On these systems the Type 17 size field from SMBIOS was only recorded if the extended size field was used.
Modify the code to use the regular size field whenever it is valid (not 0xFFFF) and not set to 0x7FFF on versions >2.7 (indicating the extended size field is in use).
---
src/core/dmi.cc | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/core/dmi.cc b/src/core/dmi.cc
index fe6ad39..96b6506 100644
--- a/src/core/dmi.cc
+++ b/src/core/dmi.cc
@@ -1567,15 +1567,14 @@ int dmiversionrev)
// size
u = data[0x0D] << 8 | data[0x0C];
- if ((dmiversionmaj > 2)
- || ((dmiversionmaj == 2) && (dmiversionmin >= 7))) {
- if(u == 0x7FFF) {
- unsigned long long extendsize = (data[0x1F] << 24) | (data[0x1E] << 16) | (data[0x1D] << 8) | data[0x1C];
- extendsize &= 0x7FFFFFFFUL;
- size = extendsize * 1024ULL * 1024ULL;
- }
+ if (((dmiversionmaj > 2)
+ || ((dmiversionmaj == 2) && (dmiversionmin >= 7)))
+ && u == 0x7FFF) {
+ unsigned long long extendsize = (data[0x1F] << 24) | (data[0x1E] << 16) | (data[0x1D] << 8) | data[0x1C];
+ extendsize &= 0x7FFFFFFFUL;
+ size = extendsize * 1024ULL * 1024ULL;
}
- else
+ else
if (u != 0xFFFF)
size = (1024ULL * (u & 0x7FFF) * ((u & 0x8000) ? 1 : 1024ULL));
description += string(dmi_memory_device_form_factor(data[0x0E]));
--
2.29.2