1
0
forked from pool/util-linux
util-linux/util-linux-lscpu-cleanup-DMI-detection-return-codes.patch
Dominique Leuenberger 4b2cc68e64 Accepting request 504843 from Base:System
- don't conflict with sysvinit-tools in Tumblweed anymore. Needed for Leap 15
  which wants to use a different release number scheme (lp150.x which produces
  lower numbers than the conflict).
- Update to version 2.30:
  * Many changes and improvements, most notably:
    * The libblkid library has been improved for hybrid CDROM/DVD
      media.
    * The deprecated command tailf has been removed. Use "tail -f"
      from coreutils.
    * blkzone -- NEW COMMAND to run zone commands on block devices
      that support Zoned Block Commands (ZBC) or Zoned-device ATA
      Commands (ZAC).
    * fincore -- NEW COMMAND to count pages of file contents in
      core (memory).
    * lsmem -- NEW COMMAND to list the ranges of available memory
      with their online status.
    * The command fallocate -- supports an "insert range" operation
      now.
    * The command "column -t|--table" has been modified to use
      libsmartcols. It now provides nearly all of that library's
      functionality from the command line.
  * Security issues:
    * hwclock - no longer makes any internal permission checks. The
      System Administrator must set proper permissions to control
      user access to the RTC. It is NOT recommended to use SUID.
    * CVE-2016-2779 - This security issue is NOT FIXED yet.
  * More details at:
    https://www.kernel.org/pub/linux/utils/util-linux/v2.30/v2.30-ReleaseNotes
- Drop upstreamed patch
  arm64-lscpu-use-sysfs-for-table-access-if-available.patch
- Refreshed patch
  util-linux-losetup-Add-support-for-setting-logical-blocksize.patch 
- fix compiler warnings for mkzimage_cmdline
- When when hypervisor_decode_sysfw fails continue with other
  detection methods (bsc#1042991, bsc#1039360, bsc#1033718)
  + util-linux-lscpu-cleanup-DMI-detection-return-codes.patch

OBS-URL: https://build.opensuse.org/request/show/504843
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/util-linux?expand=0&rev=218
2017-06-29 12:58:21 +00:00

86 lines
2.3 KiB
Diff

From c972852b29391c35b1d5c7d3e1e6413e0cc86908 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 13 Jun 2017 12:15:11 +0200
Subject: [PATCH] lscpu: cleanup DMI detection return codes
Michal wrote:
There is weird mix of logic in lscpu-dmi.c which sometimes returns 0 and
sometimes -1 on error. Since most checks are if (rc) goto done; this
bails out early on error skipping some detection methods. Further, in
lscpu.c all following detections are guarder by if(hyper) so returning
-1 causes all following methods to be skipped.
Reported-by: Michal Suchanek <msuchanek@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
---
sys-utils/lscpu-dmi.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/sys-utils/lscpu-dmi.c b/sys-utils/lscpu-dmi.c
index 3ba999124a2e..4b845b97ccd9 100644
--- a/sys-utils/lscpu-dmi.c
+++ b/sys-utils/lscpu-dmi.c
@@ -174,7 +174,7 @@ done:
static int hypervisor_decode_legacy(uint8_t *buf, const char *devmem)
{
if (!checksum(buf, 0x0F))
- return HYPER_NONE;
+ return -1;
return hypervisor_from_dmi_table(DWORD(buf + 0x08), WORD(buf + 0x06),
WORD(buf + 0x0C),
@@ -254,11 +254,15 @@ int read_hypervisor_dmi(void)
|| sizeof(uint16_t) != 2
|| sizeof(uint32_t) != 4
|| '\0' != 0)
- return rc;
+ goto done;
+ /* -1 : no DMI in /sys,
+ * 0 : DMI exist, nothing detected (HYPER_NONE)
+ * >0 : hypervisor detected
+ */
rc = hypervisor_decode_sysfw();
- if (rc >= 0)
- return rc;
+ if (rc >= HYPER_NONE)
+ goto done;
/* First try EFI (ia64, Intel-based Mac) */
switch (address_from_efi(&fp)) {
@@ -273,8 +277,9 @@ int read_hypervisor_dmi(void)
goto done;
rc = hypervisor_decode_smbios(buf, _PATH_DEV_MEM);
- if (rc)
+ if (rc >= HYPER_NONE)
goto done;
+
free(buf);
buf = NULL;
memory_scan:
@@ -287,17 +292,17 @@ memory_scan:
for (fp = 0; fp <= 0xFFF0; fp += 16) {
if (memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0) {
rc = hypervisor_decode_smbios(buf + fp, _PATH_DEV_MEM);
- if (rc == -1)
+ if (rc < 0)
fp += 16;
} else if (memcmp(buf + fp, "_DMI_", 5) == 0)
rc = hypervisor_decode_legacy(buf + fp, _PATH_DEV_MEM);
- if (rc >= 0)
+ if (rc >= HYPER_NONE)
break;
}
#endif
done:
free(buf);
- return rc;
+ return rc < 0 ? HYPER_NONE : rc;
}
--
2.12.3