aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-02-13 09:52:40 +0800
committerFam Zheng <famz@redhat.com>2018-03-01 15:21:46 +0800
commit78d8c99e297eba32897d8a5bdaa005670549d6f7 (patch)
tree2bc121978f94a0e4608000cf5f857ec26703b64d /block
parent6697439794f72b3501ee16bb95d16854f9981421 (diff)
block/nvme: fix Coverity reports
1) string not null terminated in sysfs_find_group_file 2) NULL pointer dereference and dead local variable in nvme_init. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <20180213015240.9352-1-famz@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/nvme.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/block/nvme.c b/block/nvme.c
index 10bffbbf2f..75078022f6 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -645,7 +645,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier,
false, nvme_handle_event, nvme_poll_cb);
- nvme_identify(bs, namespace, errp);
+ nvme_identify(bs, namespace, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EIO;
@@ -666,8 +666,12 @@ fail_queue:
nvme_free_queue_pair(bs, s->queues[0]);
fail:
g_free(s->queues);
- qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
- qemu_vfio_close(s->vfio);
+ if (s->regs) {
+ qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE);
+ }
+ if (s->vfio) {
+ qemu_vfio_close(s->vfio);
+ }
event_notifier_cleanup(&s->irq_notifier);
return ret;
}