virtio pmem: coverity fixes
cover virtio pmem: coverity fixes
This patch series two fixes for coverity and a
transactional info removal patch.
Pankaj Gupta (3):
virtio pmem: fix wrong mem region condition
virtio pmem: remove memdev null check
virtio pmem: remove transational device info
hw/virtio/virtio-pmem-pci.c | 4 +--- hw/virtio/virtio-pmem.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.5
PATCH 1/3 virtio pmem: fix wrong mem region condition
Coverity reported memory region returns zero
for non-null value. This is because of wrong
arguments to '?:' , fixing this.
--- hw/virtio/virtio-pmem-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-pmem-pci.c +1 -1
@@ -57,7 +57,7 @@ static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,MemoryRegion *mr = vpc->get_memory_region (pmem, errp);/* the plugged size corresponds to the region size */ -return mr ?0 :memory_region_size (mr); +return mr ?memory_region_size (mr) :0 ; } static void virtio_pmem_pci_fill_device_info(const MemoryDeviceState *md,
Signature · 1 line
2.14.5
Re: [Qemu-devel] [PATCH 1/3] virtio pmem: fix wrong mem region condition
Quoted 8 lines · Pankaj Gupta
Coverity reported memory region returns zero
for non-null value. This is because of wrong
arguments to '?:' , fixing this.Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
hw/virtio/virtio-pmem-pci.c +1
-1@@ -57,7 +57,7 @@ static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,MemoryRegion *mr = vpc->get_memory_region (pmem, errp);/* the plugged size corresponds to the region size */ -return mr ?0 :memory_region_size (mr); +return mr ?memory_region_size (mr) :0 ; } static void virtio_pmem_pci_fill_device_info(const MemoryDeviceState *md,Signature · 1 line
2.14.5
Re: [Qemu-devel] [PATCH 1/3] virtio pmem: fix wrong mem region condition
In reply to Pankaj GuptaQuoted 8 lines · On Fri, 12 Jul 2019 13:05:52 +0530 Pankaj Gupta <[email protected]> wrote:
Coverity reported memory region returns zero
for non-null value. This is because of wrong
arguments to '?:' , fixing this.Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [Qemu-devel] [PATCH 1/3] virtio pmem: fix wrong mem region condition
In reply to Pankaj GuptaQuoted 4 lines · Pankaj Gupta
Coverity reported memory region returns zero
for non-null value. This is because of wrong
arguments to '?:' , fixing this.
Please amend:
Quoted 1 line
Signed-off-by Pankaj Gupta <[email protected]>
Quoted 18 lines
--- hw/virtio/virtio-pmem-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-pmem-pci.c +1
-1@@ -57,7 +57,7 @@ static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,MemoryRegion *mr = vpc->get_memory_region (pmem, errp);/* the plugged size corresponds to the region size */ -return mr ?0 :memory_region_size (mr); +return mr ?memory_region_size (mr) :0 ; } static void virtio_pmem_pci_fill_device_info(const MemoryDeviceState *md,
Re: [Qemu-devel] [PATCH 1/3] virtio pmem: fix wrong mem region condition
In reply to Pankaj GuptaQuoted 15 lines · Pankaj Gupta
Coverity reported memory region returns zero
for non-null value. This is because of wrong
arguments to '?:' , fixing this.Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-pmem-pci.c +0
-0
hw/virtio/virtio-pmem-pci.c static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md, · line 63
Quoted 8 lines
hw/virtio/virtio-pmem-pci.c +1
-1@@ -57,7 +57,7 @@ static uint64_t virtio_pmem_pci_get_plugged_size(const MemoryDeviceState *md,MemoryRegion *mr = vpc->get_memory_region (pmem, errp);/* the plugged size corresponds to the region size */ -return mr ?0 :memory_region_size (mr); +return mr ?memory_region_size (mr) :0 ; } static void virtio_pmem_pci_fill_device_info(const MemoryDeviceState *md,
Signature · 3 lines
Thanks, David / dhildenb
PATCH 2/3 virtio pmem: remove memdev null check
In reply to Pankaj GuptaCoverity reports that when we're assigning vi->size we handle the "pmem->memdev is NULL" case; but we then pass it into object_get_canonical_path(), which unconditionally dereferences it and will crash if it is NULL. If this pointer can be NULL then we need to do something else here.
We are removing 'pmem->memdev' null check here as memdev will never be null in this function.
--- hw/virtio/virtio-pmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/virtio-pmem.c +2 -2
@@ -134,8 +134,8 @@ static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem, VirtioPMEMDeviceInfo *vi) { vi->memaddr = pmem->start; - vi->size = pmem->memdev ?memory_region_size (&pmem->memdev->mr) :0 ; - vi->memdev =object_get_canonical_path (OBJECT (pmem->memdev)); + vi->size =memory_region_size (&pmem->memdev->mr); + vi->memdev =object_get_canonical_path (OBJECT (pmem->memdev)); } static MemoryRegion *virtio_pmem_get_memory_region(VirtIOPMEM *pmem,
Signature · 1 line
2.14.5
Re: [Qemu-devel] [PATCH 2/3] virtio pmem: remove memdev null check
Quoted 8 lines · On Fri, 12 Jul 2019 13:05:53 +0530 Pankaj Gupta <[email protected]> wrote:
Coverity reports that when we're assigning
vi->sizewe handle the "pmem->memdevis NULL" case; but we then pass it intoobject_get_canonical_path(), which unconditionally dereferences it and will crash if it is NULL. If this pointer can be NULL then we need to do something else here.We are removing '
pmem->memdev' null check here as memdev will never be null in this function.
Indeed, we'll fail to realize the device if it is NULL.
Quoted 5 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 3/3 virtio pmem: remove transational device info
In reply to Pankaj GuptaRemove transactional & non transactional device info for virtio pmem.
--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)
hw/virtio/virtio-pmem-pci.c +0 -2
@@ -113,8 +113,6 @@ static void virtio_pmem_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = { .base_name =TYPE_VIRTIO_PMEM_PCI , .generic_name ="virtio-pmem-pci" , - .transitional_name ="virtio-pmem-pci-transitional" , - .non_transitional_name ="virtio-pmem-pci-non-transitional" , .instance_size =sizeof (VirtIOPMEMPCI), .instance_init = virtio_pmem_pci_instance_init, .class_init = virtio_pmem_pci_class_init,
Signature · 1 line
2.14.5
Re: [Qemu-devel] [PATCH 3/3] virtio pmem: remove transational device info
Quoted 2 lines · On Fri, 12 Jul 2019 13:05:54 +0530 Pankaj Gupta <[email protected]> wrote:
Remove transactional & non transactional device info for virtio pmem.
s/device info/names/ ?
Quoted 5 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)
Re: [Qemu-devel] [PATCH 3/3] virtio pmem: remove transational device info
Quoted 9 lines
Quoted 2 lines · On Fri, 12 Jul 2019 13:05:54 +0530 Pankaj Gupta <[email protected]> wrote:
Remove transactional & non transactional device info for virtio pmem.
s/device info/names/ ?
yes.
Quoted 9 lines
Quoted 6 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)Reviewed-by Cornelia Huck <[email protected]>
Re: [Qemu-devel] [PATCH 3/3] virtio pmem: remove transational device info
In reply to Pankaj GuptaQuoted 2 lines · Pankaj Gupta
Remove transactional & non transactional device info for virtio pmem.
Can you explain and add *why* ?
Quoted 20 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)hw/virtio/virtio-pmem-pci.c +0
-2@@ -113,8 +113,6 @@ static void virtio_pmem_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = { .base_name =TYPE_VIRTIO_PMEM_PCI , .generic_name ="virtio-pmem-pci" , - .transitional_name ="virtio-pmem-pci-transitional" , - .non_transitional_name ="virtio-pmem-pci-non-transitional" , .instance_size =sizeof (VirtIOPMEMPCI), .instance_init = virtio_pmem_pci_instance_init, .class_init = virtio_pmem_pci_class_init,
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH 3/3] virtio pmem: remove transational device info
Quoted 7 lines · Pankaj Gupta
Quoted 2 lines
Remove transactional & non transactional device info for virtio pmem.
Can you explain and add *why* ?
As per upstream suggestion by Cornelia & MST, transactional devices are for legacy purpose. So, does not make sense for virtio-pmem.
Thanks,
Pankaj
Quoted 29 lines
Quoted 13 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)hw/virtio/virtio-pmem-pci.c +0
-0hw/virtio/virtio-pmem-pci.c static void virtio_pmem_pci_instance_init(Object *obj) · line 118
Quoted 8 lines
hw/virtio/virtio-pmem-pci.c +0
-2@@ -113,8 +113,6 @@ static void virtio_pmem_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = { .base_name =TYPE_VIRTIO_PMEM_PCI , .generic_name ="virtio-pmem-pci" , - .transitional_name ="virtio-pmem-pci-transitional" , - .non_transitional_name ="virtio-pmem-pci-non-transitional" , .instance_size =sizeof (VirtIOPMEMPCI), .instance_init = virtio_pmem_pci_instance_init, .class_init = virtio_pmem_pci_class_init,--
Thanks,
David / dhildenb
David Hildenbrand
Reviewed-byRe: [Qemu-devel] [PATCH 3/3] virtio pmem: remove transational device info
Quoted 10 lines · Pankaj Gupta
Quoted 7 lines · Pankaj Gupta
Quoted 2 lines
Remove transactional & non transactional device info for virtio pmem.
Can you explain and add *why* ?
As per upstream suggestion by Cornelia & MST, transactional devices are for legacy purpose. So, does not make sense for virtio-pmem.
With something like that added to the description
Quoted 33 lines
Thanks,
PankajQuoted 29 lines
Quoted 13 lines
Signed-off-by Pankaj Gupta <[email protected]>--- hw/virtio/virtio-pmem-pci.c | 2 -- 1 file changed, 2 deletions(-)hw/virtio/virtio-pmem-pci.c +0
-0hw/virtio/virtio-pmem-pci.c static void virtio_pmem_pci_instance_init(Object *obj) · line 118
Quoted 8 lines
hw/virtio/virtio-pmem-pci.c +0
-2@@ -113,8 +113,6 @@ static void virtio_pmem_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_pmem_pci_info = { .base_name =TYPE_VIRTIO_PMEM_PCI , .generic_name ="virtio-pmem-pci" , - .transitional_name ="virtio-pmem-pci-transitional" , - .non_transitional_name ="virtio-pmem-pci-non-transitional" , .instance_size =sizeof (VirtIOPMEMPCI), .instance_init = virtio_pmem_pci_instance_init, .class_init = virtio_pmem_pci_class_init,--
Thanks,
David / dhildenb
Signature · 3 lines
Thanks, David / dhildenb
Quoted 12 lines · On Fri, 12 Jul 2019 13:05:51 +0530 Pankaj Gupta <[email protected]> wrote:
This patch series two fixes for coverity and a
transactional info removal patch.Pankaj Gupta (3):
virtio pmem: fix wrong mem region condition
virtio pmem: remove memdev null check
virtio pmem: remove transational device infohw/virtio/virtio-pmem-pci.c | 4 +--- hw/virtio/virtio-pmem.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-)
I think all of this is 4.1 material.
Quoted 13 lines
Quoted 8 lines · On Fri, 12 Jul 2019 13:05:51 +0530 Pankaj Gupta <[email protected]> wrote:
This patch series two fixes for coverity and a
transactional info removal patch.Pankaj Gupta (3):
virtio pmem: fix wrong mem region condition
virtio pmem: remove memdev null check
virtio pmem: remove transational device info
Quoted 6 lines
Quoted 4 lines
hw/virtio/virtio-pmem-pci.c | 4 +--- hw/virtio/virtio-pmem.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-)I think all of this is 4.1 material.
Yes, forgot to add in the subject.
Thank you for the review.
Best regards,
Pankaj