Skip to content

Commit 3cc0fec

Browse files
author
manuiiit
committed
Fixed Coverity issue "Dereference null return value"
1 parent b631da2 commit 3cc0fec

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreateCommandWrapper.java‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,19 @@ public Answer execute(final CreateCommand command, final LibvirtComputingResourc
5959
vol = libvirtComputingResource.templateToPrimaryDownload(command.getTemplateUrl(), primaryPool, dskch.getPath());
6060
} else {
6161
baseVol = primaryPool.getPhysicalDisk(command.getTemplateUrl());
62-
vol = storagePoolMgr.createDiskFromTemplate(baseVol,
63-
dskch.getPath(), dskch.getProvisioningType(), primaryPool, 0);
62+
vol = storagePoolMgr.createDiskFromTemplate(baseVol, dskch.getPath(), dskch.getProvisioningType(), primaryPool, 0);
6463
}
6564
if (vol == null) {
6665
return new Answer(command, false, " Can't create storage volume on storage pool");
6766
}
6867
} else {
6968
vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getProvisioningType(), dskch.getSize());
69+
if (vol == null) {
70+
return new Answer(command, false, " Can't create Physical Disk");
71+
}
7072
}
71-
final VolumeTO volume =
72-
new VolumeTO(command.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize, null);
73+
final VolumeTO volume = new VolumeTO(command.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize,
74+
null);
7375

7476
volume.setBytesReadRate(dskch.getBytesReadRate());
7577
volume.setBytesWriteRate(dskch.getBytesWriteRate());
@@ -82,4 +84,4 @@ public Answer execute(final CreateCommand command, final LibvirtComputingResourc
8284
return new CreateAnswer(command, e);
8385
}
8486
}
85-
}
87+
}

0 commit comments

Comments
 (0)