[libvirt] [PATCH] storage_driver: Don't crash in storagePoolCreateXML

Michal Privoznik posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/295cd39aa488e8e94455afeeac5616a789906d3d.1566566683.git.mprivozn@redhat.com
src/storage/storage_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] storage_driver: Don't crash in storagePoolCreateXML
Posted by Michal Privoznik 4 years, 8 months ago
In my recent patches I've introduced
virStoragePoolObjIsStarting() which is then used to protect
storage pool definition when the pool object is locked and
unlocked during long running jobs. Well, my patches did not
anticipate that @obj can be NULL under 'cleanup' label in
storagePoolCreateXML() (for instance when parsing XML fails).
This imperfection is causing libvirtd to crash then.

Fixes: 13284a6b83 storage_driver: Protect pool def during startup and build

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/storage/storage_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index cd9f14a2c0..30940b5dcf 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -808,7 +808,7 @@ storagePoolCreateXML(virConnectPtr conn,
     pool = virGetStoragePool(conn, def->name, def->uuid, NULL, NULL);
 
  cleanup:
-    if (virStoragePoolObjIsStarting(obj)) {
+    if (obj && virStoragePoolObjIsStarting(obj)) {
         if (!virStoragePoolObjIsActive(obj))
             virStoragePoolUpdateInactive(obj);
         virStoragePoolObjSetStarting(obj, false);
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] storage_driver: Don't crash in storagePoolCreateXML
Posted by Martin Kletzander 4 years, 8 months ago
On Fri, Aug 23, 2019 at 03:24:43PM +0200, Michal Privoznik wrote:
>In my recent patches I've introduced
>virStoragePoolObjIsStarting() which is then used to protect
>storage pool definition when the pool object is locked and
>unlocked during long running jobs. Well, my patches did not
>anticipate that @obj can be NULL under 'cleanup' label in
>storagePoolCreateXML() (for instance when parsing XML fails).
>This imperfection is causing libvirtd to crash then.
>
>Fixes: 13284a6b83 storage_driver: Protect pool def during startup and build
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list