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

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); VIR_FREE(unixfile); if (vm) virDomainObjUnlock(vm); -- 1.6.6.rc2.275.g51e2d

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

On Mon, Dec 14, 2009 at 04:49:46PM +0100, Jim Meyering wrote:
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);
ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Dec 14, 2009 at 04:42:03PM +0100, 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); VIR_FREE(unixfile); if (vm) virDomainObjUnlock(vm);
ACK, let's avoid the risk, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering