Fix Coverity issues for virtio-pci and vhost-user msg
cover Fix Coverity issues for virtio-pci and vhost-user msg
Tiwei Bie (2):
net/virtio: fix unchecked return value
vhost: remove unneeded null pointer check
drivers/net/virtio/virtio_pci.c | 10 ++++++++-- lib/librte_vhost/vhost_user.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.19.1
PATCH 1/2 net/virtio: fix unchecked return value
Coverity issue: 302861
---
This patch can't be backported because it depends on the API change introduced by below commit in this release.
commit e8d435f1f3a1 ("bus/pci: harmonize return value of config read")
drivers/net/virtio/virtio_pci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/virtio/virtio_pci.c +8 -2
@@ -614,9 +614,15 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) hw->common_cfg =get_cfg_addr (dev, &cap);break ;case VIRTIO_PCI_CAP_NOTIFY_CFG : -rte_pci_read_config (dev, &hw->notify_off_multiplier, + ret =rte_pci_read_config (dev, + &hw->notify_off_multiplier,4 , pos +sizeof (cap)); - hw->notify_base =get_cfg_addr (dev, &cap); +if (ret !=4 ) +PMD_INIT_LOG (DEBUG , +"failed to read notify_off_multiplier, ret %d" , + ret); +else + hw->notify_base =get_cfg_addr (dev, &cap);break ;case VIRTIO_PCI_CAP_DEVICE_CFG : hw->dev_cfg =get_cfg_addr (dev, &cap);
Signature · 1 line
2.19.1
Re: [PATCH 1/2] net/virtio: fix unchecked return value
Quoted 26 lines · Tiwei Bie
Coverity issue: 302861
Fixes 6ba1f63b5ab0 ("virtio: support specification 1.0")Signed-off-by Tiwei Bie <[email protected]>---
This patch can't be backported because it depends on the API change introduced by below commit in this release.commit
e8d435f1f3a1("bus/pci: harmonize return value of config read")drivers/net/virtio/virtio_pci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/net/virtio/virtio_pci.c +2
-1@@ -614,9 +614,15 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) hw->common_cfg =get_cfg_addr (dev, &cap);break ;case VIRTIO_PCI_CAP_NOTIFY_CFG : -rte_pci_read_config (dev, &hw->notify_off_multiplier, + ret =rte_pci_read_config (dev, + &hw->notify_off_multiplier,4 , pos +sizeof (cap));
drivers/net/virtio/virtio_pci.c virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) · line 628
Quoted 10 lines
drivers/net/virtio/virtio_pci.c +6
-1- hw->notify_base =get_cfg_addr (dev, &cap); +if (ret !=4 ) +PMD_INIT_LOG (DEBUG , +"failed to read notify_off_multiplier, ret %d" , + ret); +else + hw->notify_base =get_cfg_addr (dev, &cap);break ;case VIRTIO_PCI_CAP_DEVICE_CFG : hw->dev_cfg =get_cfg_addr (dev, &cap);
Thanks,
Maxime
PATCH 2/2 vhost: remove unneeded null pointer check
In reply to Tiwei BieThe caller will guarantee that msg won't be null. Remove the unneeded null pointer check which caused a Coverity warning.
Coverity issue: 323484
--- lib/librte_vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_vhost/vhost_user.c +1 -1
@@ -1732,7 +1732,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg)if (ret <=0 )return ret; -if (msg && msg->size) { +if (msg->size) {if (msg->size >sizeof (msg->payload)) {RTE_LOG (ERR ,VHOST_CONFIG ,"invalid msg size: %d\n" , msg->size);
Signature · 1 line
2.19.1
Re: [PATCH 2/2] vhost: remove unneeded null pointer check
Quoted 19 lines · Tiwei Bie
The caller will guarantee that msg won't be null. Remove the unneeded null pointer check which caused a Coverity warning.
Coverity issue: 323484
Fixes 8f972312b8f4 ("vhost: support vhost-user")Signed-off-by Tiwei Bie <[email protected]>--- lib/librte_vhost/vhost_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_vhost/vhost_user.c +0
-0
lib/librte_vhost/vhost_user.c read_vhost_message(int sockfd, struct VhostUserMsg *msg) · line 1738
Quoted 8 lines
lib/librte_vhost/vhost_user.c +1
-1@@ -1732,7 +1732,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg)if (ret <=0 )return ret; -if (msg && msg->size) { +if (msg->size) {if (msg->size >sizeof (msg->payload)) {RTE_LOG (ERR ,VHOST_CONFIG ,"invalid msg size: %d\n" , msg->size);
Thanks,
Maxime
Maxime Coquelin
AppliedQuoted 8 lines · Tiwei Bie
Tiwei Bie (2):
net/virtio: fix unchecked return value
vhost: remove unneeded null pointer checkdrivers/net/virtio/virtio_pci.c | 10 ++++++++-- lib/librte_vhost/vhost_user.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-)
Applied to dpdk-next-virtio/master
Thanks,
Maxime