storage: util: steal cmd in CreateQemuImgCmdFromVol

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2021-12-10 17:19:18 +01:00
parent 42823e67dc
commit fd206c2867

View File

@ -1116,7 +1116,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObj *pool,
const char *inputSecretPath, const char *inputSecretPath,
virStorageVolEncryptConvertStep convertStep) virStorageVolEncryptConvertStep convertStep)
{ {
virCommand *cmd = NULL; g_autoptr(virCommand) cmd = NULL;
struct _virStorageBackendQemuImgInfo info = { struct _virStorageBackendQemuImgInfo info = {
.format = vol->target.format, .format = vol->target.format,
.type = NULL, .type = NULL,
@ -1246,11 +1246,10 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObj *pool,
} }
VIR_FREE(info.secretAlias); VIR_FREE(info.secretAlias);
return cmd; return g_steal_pointer(&cmd);
error: error:
VIR_FREE(info.secretAlias); VIR_FREE(info.secretAlias);
virCommandFree(cmd);
return NULL; return NULL;
} }