hw/block/nvme: fix zone management receive reporting too many zones
commit3754df04ec291b933c18285210793d02c9d9787a
authorKlaus Jensen <k.jensen@samsung.com>
Tue, 9 Mar 2021 14:11:42 +0000 (9 15:11 +0100)
committerKlaus Jensen <k.jensen@samsung.com>
Thu, 18 Mar 2021 11:34:51 +0000 (18 12:34 +0100)
tree45125cda78ec8cea50f6f26729fea213c134d7fb
parent3921756dee6dd7beb7b60167f368e8b981c77365
hw/block/nvme: fix zone management receive reporting too many zones

nvme_zone_mgmt_recv uses nvme_ns_nlbas() to get the number of LBAs in
the namespace and then calculates the number of zones to report by
incrementing slba with ZSZE until exceeding the number of LBAs as
returned by nvme_ns_nlbas().

This is bad because the namespace might be of such as size that some
LBAs are valid, but are not part of any zone, causing zone management
receive to report one additional (but non-existing) zone.

Fix this with a conventional loop on i < ns->num_zones instead.

Fixes: a479335bfaf3 ("hw/block/nvme: Support Zoned Namespace Command Set")
Cc: Dmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
hw/block/nvme.c