Skip to content

Commit

Permalink
virtio-blk: handle malloc failure
Browse files Browse the repository at this point in the history
Signed-off-by: David Scott <[email protected]>
  • Loading branch information
djs55 committed Mar 6, 2020
1 parent 6d0f4d1 commit 11dae8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/pci_virtio_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ pci_vtblk_init(struct pci_devinst *pi, char *opts)

/* Customise the capabilities per-device */
vi_consts = (struct virtio_consts*)malloc(sizeof(struct virtio_consts));
if (vi_consts == NULL){
perror("Failed to allocate buffer for virtio_consts");
return (1);
}
*vi_consts = vtblk_vi_consts_defaults;
if (!blockif_candelete(bctxt)){
/* Don't tell the guest we can discard if the backing device doesn't support it */
Expand Down

0 comments on commit 11dae8f

Please sign in to comment.