[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu_driver.c: don't unlink(NULL) on OOM error path



Jim Meyering wrote:

> Not terribly likely, but not impossible, either:
>
>>From dc8fe76ed209d04b1e962b94b20da17a077e102f Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Mon, 14 Dec 2009 16:41:11 +0100
> Subject: [PATCH] qemu_driver.c: don't unlink(NULL) on OOM error path
>
> * src/qemu/qemu_driver.c (qemudDomainMigratePrepareTunnel): Upon an
> out of memory error, we would end up with unixfile==NULL and attempt
> to unlink(NULL).  Skip the unlink when it's NULL.
> ---
>  src/qemu/qemu_driver.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 56bcec5..04b2511 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -6903,7 +6903,8 @@ endjob:
>
>  cleanup:
>      virDomainDefFree(def);
> -    unlink(unixfile);
> +    if (unixfile)
> +      unlink(unixfile);

Oops.
Should have indented by 4, not 2.
Adjusted that:

>From d73b657113804a092473a5fa59ad00d105c7dbaa Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Mon, 14 Dec 2009 16:41:11 +0100
Subject: [PATCH] qemu_driver.c: don't unlink(NULL) on OOM error path

* src/qemu/qemu_driver.c (qemudDomainMigratePrepareTunnel): Upon an
out of memory error, we would end up with unixfile==NULL and attempt
to unlink(NULL).  Skip the unlink when it's NULL.
---
 src/qemu/qemu_driver.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 56bcec5..c782f0d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6903,7 +6903,8 @@ endjob:

 cleanup:
     virDomainDefFree(def);
-    unlink(unixfile);
+    if (unixfile)
+        unlink(unixfile);
     VIR_FREE(unixfile);
     if (vm)
         virDomainObjUnlock(vm);
--
1.6.6.rc2.275.g51e2d


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]