mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
storage: avoid null deref and leak on failure
Detected by clang. NULL deref added in commit 343a27a (Mar 11), but leak of voldef present since commit 2cd9b2d (Apr 09). * src/storage/storage_driver.c (storageVolumeCreateXML): Don't leak voldef or dereference null volobj.
This commit is contained in:
parent
6eb3a1f4f7
commit
4644f0b253
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_driver.c: core driver for storage APIs
|
* storage_driver.c: core driver for storage APIs
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2010 Red Hat, Inc.
|
* Copyright (C) 2006-2011 Red Hat, Inc.
|
||||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -1319,8 +1319,12 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
|
|||||||
pool->volumes.objs[pool->volumes.count++] = voldef;
|
pool->volumes.objs[pool->volumes.count++] = voldef;
|
||||||
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
|
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
|
||||||
voldef->key);
|
voldef->key);
|
||||||
|
if (!volobj) {
|
||||||
|
pool->volumes.count--;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (volobj && backend->buildVol) {
|
if (backend->buildVol) {
|
||||||
int buildret;
|
int buildret;
|
||||||
virStorageVolDefPtr buildvoldef = NULL;
|
virStorageVolDefPtr buildvoldef = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user