qemu: block: Break out early on invalid storage sources

Return NULL right away in qemuBlockStorageSourceGetBackendProps when an
invalid storage source is presented so that virJSONValueObjectAdd isn't
called with a NULL argument.

Found by coverity.
This commit is contained in:
Peter Krempa 2017-11-09 10:13:26 +01:00
parent 19448a2561
commit bb15ac4599

View File

@ -958,7 +958,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
case VIR_STORAGE_TYPE_VOLUME: case VIR_STORAGE_TYPE_VOLUME:
case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_NONE:
case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_LAST:
break; return NULL;
case VIR_STORAGE_TYPE_NETWORK: case VIR_STORAGE_TYPE_NETWORK:
switch ((virStorageNetProtocol) src->protocol) { switch ((virStorageNetProtocol) src->protocol) {
@ -1008,7 +1008,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSourcePtr src)
case VIR_STORAGE_NET_PROTOCOL_NONE: case VIR_STORAGE_NET_PROTOCOL_NONE:
case VIR_STORAGE_NET_PROTOCOL_LAST: case VIR_STORAGE_NET_PROTOCOL_LAST:
break; return NULL;
} }
break; break;
} }