[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen stable-4.19] hw/nvme: fix null pointer access in directive receive



commit 43328764f7a0c4371f0142a8cee6dcdbeecfa633
Author:     Klaus Jensen <k.jensen@xxxxxxxxxxx>
AuthorDate: Tue Aug 8 17:16:13 2023 +0200
Commit:     Michael Tokarev <mjt@xxxxxxxxxx>
CommitDate: Sun Sep 10 19:39:41 2023 +0300

    hw/nvme: fix null pointer access in directive receive
    
    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@xxxxxxxxxx
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1815
    Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
    Reviewed-by: Jesper Wendel Devantier <j.devantier@xxxxxxxxxxx>
    Signed-off-by: Klaus Jensen <k.jensen@xxxxxxxxxxx>
    (cherry picked from commit 6c8f8456cb0b239812dee5211881426496da7b98)
    Signed-off-by: Michael Tokarev <mjt@xxxxxxxxxx>
---
 hw/nvme/ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 00b910ca9e..ac505727e5 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -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;
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#stable-4.19



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.