diff options
author | Klaus Jensen <k.jensen@samsung.com> | 2023-05-24 11:45:04 +0200 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2023-06-28 11:22:42 +0200 |
commit | 94fa8ca7ee9b6215a5c078f5d424377e5fa61b9c (patch) | |
tree | e5e54e4a02bda5d7bba0a392fb072d314d463576 /hw/nvme/ns.c | |
parent | 3ae8a54a087d54cfd109ab3d844ff4cba54a28d8 (diff) | |
download | qemu-94fa8ca7ee9b6215a5c078f5d424377e5fa61b9c.zip qemu-94fa8ca7ee9b6215a5c078f5d424377e5fa61b9c.tar.gz qemu-94fa8ca7ee9b6215a5c078f5d424377e5fa61b9c.tar.bz2 |
hw/nvme: verify uniqueness of reclaim unit handle identifiers
Verify that a reclaim unit handle identifier is only specified once in
fdp.ruhs.
Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
Reviewed-by: Jesper Wendel Devantier <j.devantier@samsung.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Diffstat (limited to 'hw/nvme/ns.c')
-rw-r--r-- | hw/nvme/ns.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 050fdaf..c4ea203 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -453,6 +453,17 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) free(r); + /* verify that the ruhids are unique */ + for (unsigned int i = 0; i < ns->fdp.nphs; i++) { + for (unsigned int j = i + 1; j < ns->fdp.nphs; j++) { + if (ruhids[i] == ruhids[j]) { + error_setg(errp, "duplicate reclaim unit handle identifier: %u", + ruhids[i]); + return false; + } + } + } + ph = ns->fdp.phs = g_new(uint16_t, ns->fdp.nphs); ruhid = ruhids; |