[libvirt] [PATCH] qemu_driver: avoid NULL dereference

Cole Robinson crobinso at redhat.com
Mon May 17 13:46:32 UTC 2010


On 05/17/2010 07:04 AM, Jim Meyering wrote:

> 
>>From f88969b986a1c88985671c9d6fa9cb1dc449ed74 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Mon, 17 May 2010 12:10:52 +0200
> Subject: [PATCH] qemu_driver: avoid NULL dereference
> 
> * src/qemu/qemu_driver.c (qemudDomainStart): After setting vm to NULL,
> goto cleanup, rather than dereferencing the NULL pointer.
> ---
>  src/qemu/qemu_driver.c |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 8f69b5a..3559e36 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6489,8 +6489,11 @@ static int qemudDomainStart(virDomainPtr dom) {
>           * We should still have a reference left to vm but
>           * one should check for 0 anyway
>           */
> -        if (qemuDomainObjEndJob(vm) == 0)
> +        if (qemuDomainObjEndJob(vm) = 0) {

An '=' went missing here. Assuming it was unitentional, and since it was
breaking the build with --enable-compile-warnings=error, I pushed this:

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5f1d6b5..ab6bec8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6489,7 +6489,7 @@ static int qemudDomainStart(virDomainPtr dom) {
          * We should still have a reference left to vm but
          * one should check for 0 anyway
          */
-        if (qemuDomainObjEndJob(vm) = 0) {
+        if (qemuDomainObjEndJob(vm) == 0) {
             vm = NULL;
             goto cleanup;
         }

- Cole




More information about the libvir-list mailing list