summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu-topology.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /sys-utils/lscpu-topology.c
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sys-utils/lscpu-topology.c')
-rw-r--r--sys-utils/lscpu-topology.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys-utils/lscpu-topology.c b/sys-utils/lscpu-topology.c
index 754b3fc..e3742e3 100644
--- a/sys-utils/lscpu-topology.c
+++ b/sys-utils/lscpu-topology.c
@@ -1,3 +1,14 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Copyright (C) 2008 Cai Qian <qcai@redhat.com>
+ * Copyright (C) 2008-2023 Karel Zak <kzak@redhat.com>
+ */
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -242,7 +253,8 @@ struct lscpu_cache *lscpu_cpu_get_cache(struct lscpu_cxt *cxt,
for (i = 0; i < cxt->ncaches; i++) {
struct lscpu_cache *ca = &cxt->caches[i];
- if (strcmp(ca->name, name) == 0 &&
+ if (ca->sharedmap &&
+ strcmp(ca->name, name) == 0 &&
CPU_ISSET_S(cpu->logical_id, cxt->setsize, ca->sharedmap))
return ca;
}
@@ -274,8 +286,8 @@ static struct lscpu_cache *add_cache(struct lscpu_cxt *cxt,
struct lscpu_cache *ca;
cxt->ncaches++;
- cxt->caches = xrealloc(cxt->caches,
- cxt->ncaches * sizeof(*cxt->caches));
+ cxt->caches = xreallocarray(cxt->caches,
+ cxt->ncaches, sizeof(*cxt->caches));
ca = &cxt->caches[cxt->ncaches - 1];
memset(ca, 0 , sizeof(*ca));