hw/block/nvme: fix uint16_t use of uint32_t sgls member
authorKlaus Jensen <k.jensen@samsung.com>
Wed, 4 Nov 2020 10:22:47 +0000 (11:22 +0100)
committerMax Reitz <mreitz@redhat.com>
Mon, 9 Nov 2020 14:44:21 +0000 (15:44 +0100)
nvme_map_sgl_data erroneously uses the sgls member of NvmeIdNs as a
uint16_t.

Reported-by: Coverity (CID 1436129)
Fixes: cba0a8a344fe ("hw/block/nvme: add support for scatter gather lists")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Message-Id: <20201104102248.32168-3-its@irrelevant.dk>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
hw/block/nvme.c

index 080d782f1c2b110fc99f2bdcc6458f56be801fa2..2bdc50eb6fceb7f7d2bc62d979b6400ad8add5d2 100644 (file)
@@ -452,7 +452,7 @@ static uint16_t nvme_map_sgl_data(NvmeCtrl *n, QEMUSGList *qsg,
              * segments and/or descriptors. The controller might accept
              * ignoring the rest of the SGL.
              */
-            uint16_t sgls = le16_to_cpu(n->id_ctrl.sgls);
+            uint32_t sgls = le32_to_cpu(n->id_ctrl.sgls);
             if (sgls & NVME_CTRL_SGLS_EXCESS_LENGTH) {
                 break;
             }