[libvirt] [PATCH 0/2] A couple coverity patches

Coverity has been tripped up a few more times recently... The memory leak patch probably I what I noted from Jiri's recent CPU series. The return value check is older. It wasn't clear though if the intention of the module was to ignore errors so I just chose to error out like other similar callers. If there's a better way - then other patches can be posted. John Ferlan (2): cpu_x86: Fix memory leak - virCPUx86GetHost cpu_x86: Handle error in x86DataToCPU when calling x86DataAdd src/cpu/cpu_x86.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.20.1

Commit 56b254dcc called virCPUx86DataAdd, but returned -1 directly without calling the virCPUx86DataFree. Found by Coverity. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/cpu/cpu_x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 71fc365139..978a60c90a 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2791,7 +2791,7 @@ virCPUx86GetHost(virCPUDefPtr cpu, }; if (virCPUx86DataAdd(cpuData, &item) < 0) - return -1; + goto cleanup; } } -- 2.20.1

Commit 9c9620af called x86DataAdd without checking for an error, so add the error checking. Found by Coverity Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/cpu/cpu_x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 978a60c90a..55b55da784 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -822,7 +822,8 @@ x86DataToCPU(const virCPUx86Data *data, for (blocker = hvModel->blockers; *blocker; blocker++) { if ((feature = x86FeatureFind(map, *blocker)) && !x86DataIsSubset(©, &feature->data)) - x86DataAdd(&modelData, &feature->data); + if (x86DataAdd(&modelData, &feature->data) < 0) + goto error; } } -- 2.20.1

On 6/21/19 9:43 PM, John Ferlan wrote:
Coverity has been tripped up a few more times recently... The memory leak patch probably I what I noted from Jiri's recent CPU series. The return value check is older. It wasn't clear though if the intention of the module was to ignore errors so I just chose to error out like other similar callers. If there's a better way - then other patches can be posted.
John Ferlan (2): cpu_x86: Fix memory leak - virCPUx86GetHost cpu_x86: Handle error in x86DataToCPU when calling x86DataAdd
src/cpu/cpu_x86.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
John Ferlan
-
Michal Prívozník