Skip to content

Commit

Permalink
hw/nvme: fix null pointer access in directive receive
Browse files Browse the repository at this point in the history
nvme_directive_receive() does not check if an endurance group has been
configured (set) prior to testing if flexible data placement is enabled
or not.

Fix this.

Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1815
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>
(cherry picked from commit 6c8f845)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
birkelund authored and Michael Tokarev committed Sep 10, 2023
1 parent f47369c commit 4332876
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/nvme/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -6877,7 +6877,7 @@ static uint16_t nvme_directive_receive(NvmeCtrl *n, NvmeRequest *req)
case NVME_DIRECTIVE_IDENTIFY:
switch (doper) {
case NVME_DIRECTIVE_RETURN_PARAMS:
if (ns->endgrp->fdp.enabled) {
if (ns->endgrp && ns->endgrp->fdp.enabled) {
id.supported |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT;
id.enabled |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT;
id.persistent |= 1 << NVME_DIRECTIVE_DATA_PLACEMENT;
Expand Down

0 comments on commit 4332876

Please sign in to comment.