mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-06 01:57:31 +03:00
storage: Fix a potential crash when creating vol object
If the vol object is newly created, it increases the volumes count, but doesn't decrease the volumes count when do cleanup. It can cause libvirtd to crash when one trying to free the volume objects like: for (i = 0; i < pool->volumes.count; i++) virStorageVolDefFree(pool->volumes.objs[i]); It's more reliable if we add the newly created vol object in the end.
This commit is contained in:
parent
fe7fc1617c
commit
380f326955
@ -110,7 +110,6 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool,
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
pool->volumes.objs[pool->volumes.count++] = vol;
|
||||
}
|
||||
|
||||
if (vol->target.path == NULL) {
|
||||
@ -254,6 +253,9 @@ virStorageBackendLogicalMakeVol(virStoragePoolObjPtr pool,
|
||||
vol->source.nextent++;
|
||||
}
|
||||
|
||||
if (is_new_vol)
|
||||
pool->volumes.objs[pool->volumes.count++] = vol;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
|
Loading…
x
Reference in New Issue
Block a user