hw/nvme: two fixes
cover hw/nvme: two fixes
From: Klaus Jensen <[email protected]>
Fix two potential accesses to null pointers.
Klaus Jensen (2):
hw/nvme: fix null pointer access in directive receive hw/nvme: fix null pointer access in ruh update
hw/nvme/ctrl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/2 hw/nvme: fix null pointer access in directive receive
From: Klaus Jensen <[email protected]>
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: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1815
--- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/nvme/ctrl.c +1 -1
@@ -6900,7 +6900,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 ;
Signature · 1 line
2.41.0
PATCH 2/2 hw/nvme: fix null pointer access in ruh update
In reply to Klaus JensenFrom: Klaus Jensen <[email protected]>
The Reclaim Unit Update operation in I/O Management Receive does not verify the presence of a configured endurance group prior to accessing it.
Fix this.
--- hw/nvme/ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/nvme/ctrl.c +7 -1
@@ -4361,7 +4361,13 @@ static uint16_t nvme_io_mgmt_send_ruh_update(NvmeCtrl *n, NvmeRequest *req)uint32_t npid = (cdw10 >>1 ) +1 ;unsigned int i =0 ; g_autofree uint16_t *pids = NULL; -uint32_t maxnpid = n->subsys->endgrp.fdp.nrg * n->subsys->endgrp.fdp.nruh; +uint32_t maxnpid; + +if (!ns->endgrp || !ns->endgrp->fdp.enabled) { +return NVME_FDP_DISABLED |NVME_DNR ; + } + + maxnpid = n->subsys->endgrp.fdp.nrg * n->subsys->endgrp.fdp.nruh;if (unlikely (npid >=MIN (NVME_FDP_MAXPIDS , maxnpid))) {return NVME_INVALID_FIELD |NVME_DNR ;
Signature · 1 line
2.41.0
Quoted 15 lines · Klaus Jensen
From: Klaus Jensen <[email protected]>
Fix two potential accesses to null pointers.
Klaus Jensen (2):
hw/nvme: fix null pointer access in directive receive hw/nvme: fix null pointer access in ruh updatehw/nvme/ctrl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)Signature · 1 line
2.41.0