Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
hw/nvme: verify uniqueness of reclaim unit handle identifiers
Verify that a reclaim unit handle identifier is only specified once in
fdp.ruhs.

Fixes: 73064ed ("hw/nvme: flexible data placement emulation")
Reviewed-by: Jesper Wendel Devantier <j.devantier@samsung.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
  • Loading branch information
birkelund committed Jun 28, 2023
1 parent 3ae8a54 commit 94fa8ca
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hw/nvme/ns.c
Expand Up @@ -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;
Expand Down

0 comments on commit 94fa8ca

Please sign in to comment.