提交 380f3269 编写于 作者: O Osier Yang

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.
上级 fe7fc161
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册