提交 c668cd50 编写于 作者: J John Ferlan

Coverity: Resolve a RESOURCE_LEAK

On error the lofd would have been leaked.
上级 e38264f3
......@@ -383,6 +383,7 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
int lofd;
char *loname = NULL;
const char *src = virDomainDiskGetSource(disk);
int ret = -1;
if ((lofd = virFileLoopDeviceAssociate(src, &loname)) < 0)
return -1;
......@@ -395,13 +396,18 @@ static int virLXCControllerSetupLoopDeviceDisk(virDomainDiskDefPtr disk)
* the rest of container setup 'just works'
*/
virDomainDiskSetType(disk, VIR_DOMAIN_DISK_TYPE_BLOCK);
if (virDomainDiskSetSource(disk, loname) < 0) {
VIR_FREE(loname);
return -1;
}
if (virDomainDiskSetSource(disk, loname) < 0)
goto cleanup;
ret = 0;
cleanup:
VIR_FREE(loname);
if (ret < 0)
VIR_FORCE_CLOSE(lofd);
return lofd;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册