Skip to contentSkip to conversation

hw/nvme: fix missing variable initializers

PATCH In review Klaus Jensen 2 participants 3 messages Aug 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/nvme: fix missing variable initializers

From: Klaus Jensen <[email protected]>

Coverity found that 'uuid', 'csi' and 'eui64' are uninitialized. While we set most of the fields, we do not explicitly set the rsvd2 field in the NvmeIdNsDescr header.

Fix this by explicitly zero-initializing the variables.

Reported-by Coverity (CID 1458835, 1459295 and 1459580)
Fixes 6870cfb8140d ("hw/nvme: namespace parameter for EUI-64")
---
 hw/nvme/ctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/nvme/ctrl.c +3 -3
index 43dfaeac9f54..6baf9e0420d5 100644
@@ -4663,15 +4663,15 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req)
     struct {
         NvmeIdNsDescr hdr;
         uint8_t v[NVME_NIDL_UUID];
-    } QEMU_PACKED uuid;
+    } QEMU_PACKED uuid = {};
     struct {
         NvmeIdNsDescr hdr;
         uint64_t v;
-    } QEMU_PACKED eui64;
+    } QEMU_PACKED eui64 = {};
     struct {
         NvmeIdNsDescr hdr;
         uint8_t v;
-    } QEMU_PACKED csi;
+    } QEMU_PACKED csi = {};
 
     trace_pci_nvme_identify_ns_descr_list(nsid);
 
Signature · 1 line
2.32.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Coverity found that 'uuid', 'csi' and 'eui64' are uninitialized. While we set most of the fields, we do not explicitly set the rsvd2 field in the NvmeIdNsDescr header.

Fix this by explicitly zero-initializing the variables.

Quoted 7 lines
Reported-by Coverity (CID 1458835, 1459295 and 1459580)
Fixes 6870cfb8140d ("hw/nvme: namespace parameter for EUI-64")
---
 hw/nvme/ctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#2 lore raw
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Klaus Jensen

From: Klaus Jensen <[email protected]>

Coverity found that 'uuid', 'csi' and 'eui64' are uninitialized. While we set most of the fields, we do not explicitly set the rsvd2 field in the NvmeIdNsDescr header.

Fix this by explicitly zero-initializing the variables.

Quoted 7 lines
Reported-by Coverity (CID 1458835, 1459295 and 1459580)
Fixes 6870cfb8140d ("hw/nvme: namespace parameter for EUI-64")
---
 hw/nvme/ctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Quoted 2 lines

Swift as always Philippe, thanks!

Yes, I'll PR this for -rc3 immediately.