[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name()
From: |
Gavin Shan |
Subject: |
[PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name() |
Date: |
Thu, 7 Sep 2023 10:35:39 +1000 |
Improve sparc_cpu_class_by_name() by validating @oc, to ensure it's
child of TYPE_SPARC_CPU since it's possible for other types of classes
to have TYPE_SPARC_CPU as the suffix of their type names.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
target/sparc/cpu.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 130ab8f578..20417707da 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -745,7 +745,12 @@ static ObjectClass *sparc_cpu_class_by_name(const char
*cpu_model)
typename = sparc_cpu_type_name(cpu_model);
oc = object_class_by_name(typename);
g_free(typename);
- return oc;
+ if (object_class_dynamic_cast(oc, TYPE_SPARC_CPU) &&
+ !object_class_is_abstract(oc)) {
+ return oc;
+ }
+
+ return NULL;
}
static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
--
2.41.0
- Re: [PATCH v3 15/32] target/s390x: Use generic helper to show CPU model names, (continued)
Re: [PATCH v3 15/32] target/s390x: Use generic helper to show CPU model names, Thomas Huth, 2023/09/07
[PATCH v3 16/32] target/sh4: Use generic helper to show CPU model names, Gavin Shan, 2023/09/06
[PATCH v3 17/32] target/tricore: Use generic helper to show CPU model names, Gavin Shan, 2023/09/06
[PATCH v3 18/32] target/sparc: Improve sparc_cpu_class_by_name(),
Gavin Shan <=
[PATCH v3 19/32] target/xtensa: Improve xtensa_cpu_class_by_name(), Gavin Shan, 2023/09/06
[PATCH v3 20/32] target/hppa: Implement hppa_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 21/32] target/microblaze: Implement microblaze_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 22/32] target/nios2: Implement nios2_cpu_list(), Gavin Shan, 2023/09/06
[PATCH v3 23/32] Mark cpu_list() supported on all targets, Gavin Shan, 2023/09/06
[PATCH v3 24/32] machine: Constify MachineClass::valid_cpu_types[i], Gavin Shan, 2023/09/06
[PATCH v3 25/32] machine: Use error handling when CPU type is checked, Gavin Shan, 2023/09/06
[PATCH v3 26/32] machine: Introduce helper is_cpu_type_supported(), Gavin Shan, 2023/09/06
[PATCH v3 27/32] machine: Print CPU model name instead of CPU type name, Gavin Shan, 2023/09/06