From: Jiri Denemark Date: Tue, 26 Feb 2019 07:33:08 +0000 (+0100) Subject: cpu_x86: Make sure CPU model names are unique in cpu_map X-Git-Tag: v5.2.0-rc1~365 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d7245441a473bc1f73005fd378d4a925870cce6;p=thirdparty%2Flibvirt.git cpu_x86: Make sure CPU model names are unique in cpu_map Having multiple CPU model definitions with the same name could result in unexpected behavior. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index c54b09396f..4dd10fb561 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1293,9 +1293,15 @@ x86ModelParse(xmlXPathContextPtr ctxt, void *data) { virCPUx86MapPtr map = data; - virCPUx86ModelPtr model; + virCPUx86ModelPtr model = NULL; int ret = -1; + if (x86ModelFind(map, name)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Multiple definitions of CPU model '%s'"), name); + goto cleanup; + } + if (!(model = x86ModelNew())) goto cleanup;