nvme: Fix nvme_init error handling
commit9582f357bb6f6573c9a452743d8f3ab41ba2e3fa
authorFam Zheng <famz@redhat.com>
Thu, 12 Jul 2018 02:54:20 +0000 (12 10:54 +0800)
committerFam Zheng <famz@redhat.com>
Wed, 15 Aug 2018 02:12:35 +0000 (15 10:12 +0800)
treed6055671feca217b0f24f9b7503a1db8710d643f
parenta3f9f64bf9182f949af7d7b08f7387c976957eec
nvme: Fix nvme_init error handling

It is wrong to leave this field as 1, as nvme_close() called in the
error handling code in nvme_file_open() will use it and try to free
s->queues again.

Another problem is the cleaning ups are duplicated between the fail*
labels of nvme_init() and nvme_file_open(), which calls nvme_close().

A third problem is nvme_close() misses g_free() and
event_notifier_cleanup().

Fix all of them.

Cc: qemu-stable@nongnu.org
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20180712025420.4932-1-famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
block/nvme.c