mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: block: Don't leak server JSON object from protocol generators
If creation of the main JSON object containing the storage portion of a virStorageSource would fail but we'd allocate the server structure we'd leak it. Found by coverity.
This commit is contained in:
parent
bb15ac4599
commit
9249187f5b
@ -833,13 +833,18 @@ qemuBlockStorageSourceGetNBDProps(virStorageSourcePtr src)
|
|||||||
if (!serverprops)
|
if (!serverprops)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ignore_value(virJSONValueObjectCreate(&ret,
|
if (virJSONValueObjectCreate(&ret,
|
||||||
"s:driver", "nbd",
|
"s:driver", "nbd",
|
||||||
"a:server", serverprops,
|
"a:server", serverprops,
|
||||||
"S:export", src->path,
|
"S:export", src->path,
|
||||||
"S:tls-creds", src->tlsAlias,
|
"S:tls-creds", src->tlsAlias,
|
||||||
NULL));
|
NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
serverprops = NULL;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(serverprops);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,16 +864,21 @@ qemuBlockStorageSourceGetRBDProps(virStorageSourcePtr src)
|
|||||||
if (src->auth)
|
if (src->auth)
|
||||||
username = srcPriv->secinfo->s.aes.username;
|
username = srcPriv->secinfo->s.aes.username;
|
||||||
|
|
||||||
ignore_value(virJSONValueObjectCreate(&ret,
|
if (virJSONValueObjectCreate(&ret,
|
||||||
"s:driver", "rbd",
|
"s:driver", "rbd",
|
||||||
"s:pool", src->volume,
|
"s:pool", src->volume,
|
||||||
"s:image", src->path,
|
"s:image", src->path,
|
||||||
"S:snapshot", src->snapshot,
|
"S:snapshot", src->snapshot,
|
||||||
"S:conf", src->configFile,
|
"S:conf", src->configFile,
|
||||||
"A:server", servers,
|
"A:server", servers,
|
||||||
"S:user", username,
|
"S:user", username,
|
||||||
NULL));
|
NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
servers = NULL;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(servers);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,12 +901,17 @@ qemuBlockStorageSourceGetSheepdogProps(virStorageSourcePtr src)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* libvirt does not support the 'snap-id' and 'tag' properties */
|
/* libvirt does not support the 'snap-id' and 'tag' properties */
|
||||||
ignore_value(virJSONValueObjectCreate(&ret,
|
if (virJSONValueObjectCreate(&ret,
|
||||||
"s:driver", "sheepdog",
|
"s:driver", "sheepdog",
|
||||||
"a:server", serverprops,
|
"a:server", serverprops,
|
||||||
"s:vdi", src->path,
|
"s:vdi", src->path,
|
||||||
NULL));
|
NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
serverprops = NULL;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(serverprops);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,13 +936,18 @@ qemuBlockStorageSourceGetSshProps(virStorageSourcePtr src)
|
|||||||
if (src->auth)
|
if (src->auth)
|
||||||
username = src->auth->username;
|
username = src->auth->username;
|
||||||
|
|
||||||
ignore_value(virJSONValueObjectCreate(&ret,
|
if (virJSONValueObjectCreate(&ret,
|
||||||
"s:driver", "ssh",
|
"s:driver", "ssh",
|
||||||
"s:path", src->path,
|
"s:path", src->path,
|
||||||
"a:server", serverprops,
|
"a:server", serverprops,
|
||||||
"S:user", username,
|
"S:user", username,
|
||||||
NULL));
|
NULL) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
serverprops = NULL;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virJSONValueFree(serverprops);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user