some small fixes
Subsystems (2)
cover some small fixes
A few coverity fixes, along with a fix for one of the examples meson.build files which I caught along the way.
Bruce Richardson (5):
examples/vhost_scsi: fix header check for meson build examples/vhost_scsi: fix missing NULL-check for parameter net/i40e: fix dereference before NULL check in mbuf release app/testpmd: fix variable use before NULL check net/i40e: fix dereference before check when getting EEPROM
app/test-pmd/cmdline.c | 4 ++-- drivers/net/i40e/i40e_ethdev.c | 5 +++-- drivers/net/i40e/i40e_rxtx.c | 4 ++-- examples/vhost_scsi/meson.build | 2 +- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 5 files changed, 14 insertions(+), 7 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/5 examples/vhost_scsi: fix header check for meson build
The header check for the example app was looking for virtio_scsi.h without the "linux/" prefix, which meant it was never getting found when it should have been.
--- examples/vhost_scsi/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost_scsi/meson.build +1 -1
@@ -10,7 +10,7 @@ if host_machine.system() != 'linux' build = false endif -if not cc.has_header('virtio_scsi.h') +if not cc.has_header('linux/virtio_scsi.h') build = false endif
Signature · 1 line
2.20.1
PATCH 2/5 examples/vhost_scsi: fix missing NULL-check for parameter
In reply to Bruce RichardsonCoverity points out that there is a check in the main thread loop for the ctrlr->bdev being NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.
Coverity issue: 158657
--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
examples/vhost_scsi/vhost_scsi.c +6 -0
@@ -285,6 +285,12 @@ ctrlr_worker(void *arg)cpu_set_t cpuset;pthread_t thread; +if (ctrlr ==NULL || ctrlr->bdev ==NULL ) { +fprintf (stdout,"%s: Error, invalid argument passed to worker thread\n" , + __func__); +return NULL ; + } + thread =pthread_self ();CPU_ZERO (&cpuset);CPU_SET (0 , &cpuset);
Signature · 1 line
2.20.1
PATCH 3/5 net/i40e: fix dereference before NULL check in mbuf release
In reply to Bruce RichardsonCoverity flags that the txq variable is used before it's checked for NULL.
Coverity issue: 195023
--- drivers/net/i40e/i40e_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +2 -2
@@ -2423,13 +2423,13 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)struct rte_eth_dev *dev;uint16_t i; - dev = &rte_eth_devices[txq->port_id]; -if (!txq || !txq->sw_ring) {PMD_DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" );return ; } + dev = &rte_eth_devices[txq->port_id]; +/** * vPMD tx will not set sw_ring's mbuf to NULL after free, * so need to free remains more carefully.
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 3/5] net/i40e: fix dereference before NULL check in mbuf release
In this occasion I noticed that there is a typo in the code that appears in the patch;
it should be "Pointer to txq" instead of "Pointer to rxq":
I would consider resending and fixing it on this occasion:
Quoted 4 lines
if (!txq || !txq->sw_ring) {
PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
return;
}Quoted 38 lines
Coverity flags that the txq variable is used before it's checked for NULL.
Coverity issue: 195023
Signed-off-by Bruce Richardson <[email protected]>--- drivers/net/i40e/i40e_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/i40e/i40e_rxtx.c +2
-2@@ -2423,13 +2423,13 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)struct rte_eth_dev *dev;uint16_t i; - dev = &rte_eth_devices[txq->port_id]; -if (!txq || !txq->sw_ring) {PMD_DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" );return ; } + dev = &rte_eth_devices[txq->port_id]; +/** * vPMD tx will not set sw_ring's mbuf to NULL after free, * so need to free remains more carefully.
--
2.20.1
PATCH 4/5 app/testpmd: fix variable use before NULL check
In reply to Bruce RichardsonThe value returned from rte_eth_dev_tx_offload_name() function is used for string comparison before being checked for NULL. Move the NULL check up to be done first.
Coverity issue: 279438
--- app/test-pmd/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -18306,13 +18306,13 @@ search_tx_offload(const char *name) single_offload =1 ;for (bit =0 ; bit <sizeof (single_offload) *CHAR_BIT ; bit++) { single_name =rte_eth_dev_tx_offload_name (single_offload); +if (single_name ==NULL ) +break ;if (!strcasecmp (single_name, name)) { found =1 ;break ; }else if (!strcasecmp (single_name,"UNKNOWN" ))break ; -else if (single_name ==NULL ) -break ; single_offload <<=1 ; }
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 4/5] app/testpmd: fix variable use before NULL check
PATCH 5/5 net/i40e: fix dereference before check when getting EEPROM
In reply to Bruce RichardsonAs flagged by coverity, the "info" structure is being explicitly dereferenced before being checked later for a NULL value.
Coverity issue: 277241
--- drivers/net/i40e/i40e_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +3 -2
@@ -11893,16 +11893,17 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev,struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);bool is_sfp = false;i40e_status status; -uint8_t *data = info->data; +uint8_t *data;uint32_t value =0 ;uint32_t i; -if (!info || !info->length || !data) +if (!info || !info->length || !info->data)return -EINVAL ;if (hw->phy.link_info.module_type[0 ] ==I40E_MODULE_TYPE_SFP ) is_sfp = true; + data = info->data;for (i =0 ; i < info->length; i++) {u32 offset = i + info->offset;u32 addr = is_sfp ?I40E_I2C_EEPROM_DEV_ADDR :0 ;
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH 5/5] net/i40e: fix dereference before check when getting EEPROM
v2 cover some small fixes
In reply to Bruce RichardsonA few coverity fixes, along with a fix for one of the examples meson.build files which I caught along the way.
v2: include a typo fix identified by Rami Rosen.
Bruce Richardson (5):
examples/vhost_scsi: fix header check for meson build examples/vhost_scsi: fix missing NULL-check for parameter net/i40e: fix dereference before NULL check in mbuf release app/testpmd: fix variable use before NULL check net/i40e: fix dereference before check when getting EEPROM
app/test-pmd/cmdline.c | 4 ++-- drivers/net/i40e/i40e_ethdev.c | 5 +++-- drivers/net/i40e/i40e_rxtx.c | 6 +++--- examples/vhost_scsi/meson.build | 2 +- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 5 files changed, 15 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/5 examples/vhost_scsi: fix header check for meson build
The header check for the example app was looking for virtio_scsi.h without the "linux/" prefix, which meant it was never getting found when it should have been.
--- examples/vhost_scsi/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost_scsi/meson.build +1 -1
@@ -10,7 +10,7 @@ if host_machine.system() != 'linux' build = false endif -if not cc.has_header('virtio_scsi.h') +if not cc.has_header('linux/virtio_scsi.h') build = false endif
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 1/5] examples/vhost_scsi: fix header check for meson build
Quoted 30 lines · Bruce Richardson
The header check for the example app was looking for
virtio_scsi.hwithout the "linux/" prefix, which meant it was never getting found when it should have been.Fixes 8d47a753b7cb ("examples/vhost_scsi: disable build if missing dependency")CC Maxime Coquelin <[email protected]>CC Tiwei Bie <[email protected]>CC Zhihong Wang <[email protected]>Signed-off-by Bruce Richardson <[email protected]>--- examples/vhost_scsi/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/vhost_scsi/meson.build +1
-1@@ -10,7 +10,7 @@ if host_machine.system() != 'linux' build = false endif -if not cc.has_header('virtio_scsi.h') +if not cc.has_header('linux/virtio_scsi.h') build = false endifSignature · 1 line
2.20.1
PATCH v2 2/5 examples/vhost_scsi: fix missing NULL-check for parameter
In reply to Bruce RichardsonCoverity points out that there is a check in the main thread loop for the ctrlr->bdev being NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.
Coverity issue: 158657
--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
examples/vhost_scsi/vhost_scsi.c +6 -0
@@ -285,6 +285,12 @@ ctrlr_worker(void *arg)cpu_set_t cpuset;pthread_t thread; +if (ctrlr ==NULL || ctrlr->bdev ==NULL ) { +fprintf (stdout,"%s: Error, invalid argument passed to worker thread\n" , + __func__); +return NULL ; + } + thread =pthread_self ();CPU_ZERO (&cpuset);CPU_SET (0 , &cpuset);
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter
Quoted 22 lines · Bruce Richardson
Coverity points out that there is a check in the main thread loop for the
ctrlr->bdevbeing NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.Coverity issue: 158657
Fixes db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")CC Maxime Coquelin <[email protected]>CC Tiwei Bie <[email protected]>CC Zhihong Wang <[email protected]>Signed-off-by Bruce Richardson <[email protected]>--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)examples/vhost_scsi/vhost_scsi.c +0
-0
examples/vhost_scsi/vhost_scsi.c ctrlr_worker(void *arg) · line 289
Quoted 5 lines
examples/vhost_scsi/vhost_scsi.c +2
-0@@ -285,6 +285,12 @@ ctrlr_worker(void *arg)cpu_set_t cpuset;pthread_t thread; +if (ctrlr ==NULL || ctrlr->bdev ==NULL ) { + fprintf(stdout, "%s: Error, invalid argument passed to worker thread\n",
Might be better to print to stderr.
examples/vhost_scsi/vhost_scsi.c ctrlr_worker(void *arg) · line 291
Quoted 2 lines
examples/vhost_scsi/vhost_scsi.c +2
-0+ __func__); +return NULL ;
Might be better to exit() directly like what the other error handling in this thread does:
Otherwise destroy_device() will hang on sem_wait(&exit_sem):
Thanks,
Tiwei
Quoted 8 lines
examples/vhost_scsi/vhost_scsi.c +2
-0+ } + thread =pthread_self ();CPU_ZERO (&cpuset);CPU_SET (0 , &cpuset);Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v2 2/5] examples/vhost_scsi: fix missing NULL-check for parameter
Quoted 26 lines · Tiwei Bie
Quoted 25 lines · Bruce Richardson
Coverity points out that there is a check in the main thread loop for the
ctrlr->bdevbeing NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.Coverity issue: 158657
Fixes db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")CC Maxime Coquelin <[email protected]>CC Tiwei Bie <[email protected]>CC Zhihong Wang <[email protected]>Signed-off-by Bruce Richardson <[email protected]>--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)examples/vhost_scsi/vhost_scsi.c +0
-0@@ -285,6 +285,12 @@ ctrlr_worker(void *arg)cpu_set_t cpuset;pthread_t thread;
Quoted 5 lines
examples/vhost_scsi/vhost_scsi.c ctrlr_worker(void *arg) · line 289
Quoted 2 lines
examples/vhost_scsi/vhost_scsi.c +2
-0+if (ctrlr ==NULL || ctrlr->bdev ==NULL ) { + fprintf(stdout, "%s: Error, invalid argument passed to worker thread\n",Might be better to print to stderr.
Yes, this looks a typo on my part.
Quoted 6 lines
examples/vhost_scsi/vhost_scsi.c ctrlr_worker(void *arg) · line 291
Quoted 2 lines
examples/vhost_scsi/vhost_scsi.c +2
-0+ __func__); +return NULL ;Might be better to
exit()directly like what the other error handling in this thread does:
Quoted 6 lines
Otherwise
destroy_device()will hang onsem_wait(&exit_sem):
Ok, will change in next revision
PATCH v2 3/5 net/i40e: fix dereference before NULL check in mbuf release
In reply to Bruce RichardsonCoverity flags that the txq variable is used before it's checked for NULL. Also fix typo in error message.
Coverity issue: 195023
---
V2: Fix typo or copy/paste error while fixing main issue
--- drivers/net/i40e/i40e_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_rxtx.c +3 -3
@@ -2423,13 +2423,13 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)struct rte_eth_dev *dev;uint16_t i; - dev = &rte_eth_devices[txq->port_id]; -if (!txq || !txq->sw_ring) { -PMD_DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" ); +PMD_DRV_LOG (DEBUG ,"Pointer to txq or sw_ring is NULL" );return ; } + dev = &rte_eth_devices[txq->port_id]; +/** * vPMD tx will not set sw_ring's mbuf to NULL after free, * so need to free remains more carefully.
Signature · 1 line
2.20.1
PATCH v2 4/5 app/testpmd: fix variable use before NULL check
In reply to Bruce RichardsonThe value returned from rte_eth_dev_tx_offload_name() function is used for string comparison before being checked for NULL. Move the NULL check up to be done first.
Coverity issue: 279438
--- app/test-pmd/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -18306,13 +18306,13 @@ search_tx_offload(const char *name) single_offload =1 ;for (bit =0 ; bit <sizeof (single_offload) *CHAR_BIT ; bit++) { single_name =rte_eth_dev_tx_offload_name (single_offload); +if (single_name ==NULL ) +break ;if (!strcasecmp (single_name, name)) { found =1 ;break ; }else if (!strcasecmp (single_name,"UNKNOWN" ))break ; -else if (single_name ==NULL ) -break ; single_offload <<=1 ; }
Signature · 1 line
2.20.1
PATCH v2 5/5 net/i40e: fix dereference before check when getting EEPROM
In reply to Bruce RichardsonAs flagged by coverity, the "info" structure is being explicitly dereferenced before being checked later for a NULL value.
Coverity issue: 277241
--- drivers/net/i40e/i40e_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +3 -2
@@ -11893,16 +11893,17 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev,struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);bool is_sfp = false;i40e_status status; -uint8_t *data = info->data; +uint8_t *data;uint32_t value =0 ;uint32_t i; -if (!info || !info->length || !data) +if (!info || !info->length || !info->data)return -EINVAL ;if (hw->phy.link_info.module_type[0 ] ==I40E_MODULE_TYPE_SFP ) is_sfp = true; + data = info->data;for (i =0 ; i < info->length; i++) {u32 offset = i + info->offset;u32 addr = is_sfp ?I40E_I2C_EEPROM_DEV_ADDR :0 ;
Signature · 1 line
2.20.1
v3 cover some small fixes
In reply to Bruce RichardsonA few coverity fixes, along with a fix for one of the examples meson.build files which I caught along the way.
v3: updated patch 2, to include fixes from Tiwei.
v2: include a typo fix identified by Rami Rosen.
Bruce Richardson (5):
examples/vhost_scsi: fix header check for meson build examples/vhost_scsi: fix missing NULL-check for parameter net/i40e: fix dereference before NULL check in mbuf release app/testpmd: fix variable use before NULL check net/i40e: fix dereference before check when getting EEPROM
app/test-pmd/cmdline.c | 4 ++-- drivers/net/i40e/i40e_ethdev.c | 5 +++-- drivers/net/i40e/i40e_rxtx.c | 6 +++--- examples/vhost_scsi/meson.build | 2 +- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 5 files changed, 15 insertions(+), 8 deletions(-)
Signature · 1 line
2.20.1
PATCH v3 1/5 examples/vhost_scsi: fix header check for meson build
The header check for the example app was looking for virtio_scsi.h without the "linux/" prefix, which meant it was never getting found when it should have been.
--- examples/vhost_scsi/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/vhost_scsi/meson.build +1 -1
@@ -10,7 +10,7 @@ if host_machine.system() != 'linux' build = false endif -if not cc.has_header('virtio_scsi.h') +if not cc.has_header('linux/virtio_scsi.h') build = false endif
Signature · 1 line
2.20.1
PATCH v3 2/5 examples/vhost_scsi: fix missing NULL-check for parameter
In reply to Bruce RichardsonCoverity points out that there is a check in the main thread loop for the ctrlr->bdev being NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.
Coverity issue: 158657
--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
examples/vhost_scsi/vhost_scsi.c +6 -0
@@ -285,6 +285,12 @@ ctrlr_worker(void *arg)cpu_set_t cpuset;pthread_t thread; +if (ctrlr ==NULL || ctrlr->bdev ==NULL ) { +fprintf (stderr,"%s: Error, invalid argument passed to worker thread\n" , + __func__); +exit (0 ); + } + thread =pthread_self ();CPU_ZERO (&cpuset);CPU_SET (0 , &cpuset);
Signature · 1 line
2.20.1
Re: [dpdk-dev] [PATCH v3 2/5] examples/vhost_scsi: fix missing NULL-check for parameter
Quoted 12 lines · Bruce Richardson
Coverity points out that there is a check in the main thread loop for the
ctrlr->bdevbeing NULL, but by that stage the pointer has already been dereferenced. Therefore, for safety, before we enter the loop do an initial check on the parameter structure.Coverity issue: 158657
Fixes db75c7af19bb ("examples/vhost_scsi: introduce a new sample app")CC Maxime Coquelin <[email protected]>CC Tiwei Bie <[email protected]>CC Zhihong Wang <[email protected]>
Quoted 4 lines
Signed-off-by Bruce Richardson <[email protected]>--- examples/vhost_scsi/vhost_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
PATCH v3 3/5 net/i40e: fix dereference before NULL check in mbuf release
In reply to Bruce RichardsonCoverity flags that the txq variable is used before it's checked for NULL. Also fix typo in error message.
Coverity issue: 195023
--- drivers/net/i40e/i40e_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/i40e/i40e_rxtx.c +3 -3
@@ -2423,13 +2423,13 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq)struct rte_eth_dev *dev;uint16_t i; - dev = &rte_eth_devices[txq->port_id]; -if (!txq || !txq->sw_ring) { -PMD_DRV_LOG (DEBUG ,"Pointer to rxq or sw_ring is NULL" ); +PMD_DRV_LOG (DEBUG ,"Pointer to txq or sw_ring is NULL" );return ; } + dev = &rte_eth_devices[txq->port_id]; +/** * vPMD tx will not set sw_ring's mbuf to NULL after free, * so need to free remains more carefully.
Signature · 1 line
2.20.1
PATCH v3 4/5 app/testpmd: fix variable use before NULL check
In reply to Bruce RichardsonThe value returned from rte_eth_dev_tx_offload_name() function is used for string comparison before being checked for NULL. Move the NULL check up to be done first.
Coverity issue: 279438
--- app/test-pmd/cmdline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
app/test-pmd/cmdline.c +2 -2
@@ -18311,13 +18311,13 @@ search_tx_offload(const char *name) single_offload =1 ;for (bit =0 ; bit <sizeof (single_offload) *CHAR_BIT ; bit++) { single_name =rte_eth_dev_tx_offload_name (single_offload); +if (single_name ==NULL ) +break ;if (!strcasecmp (single_name, name)) { found =1 ;break ; }else if (!strcasecmp (single_name,"UNKNOWN" ))break ; -else if (single_name ==NULL ) -break ; single_offload <<=1 ; }
Signature · 1 line
2.20.1
PATCH v3 5/5 net/i40e: fix dereference before check when getting EEPROM
In reply to Bruce RichardsonAs flagged by coverity, the "info" structure is being explicitly dereferenced before being checked later for a NULL value.
Coverity issue: 277241
--- drivers/net/i40e/i40e_ethdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +3 -2
@@ -11901,16 +11901,17 @@ static int i40e_get_module_eeprom(struct rte_eth_dev *dev,struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);bool is_sfp = false;i40e_status status; -uint8_t *data = info->data; +uint8_t *data;uint32_t value =0 ;uint32_t i; -if (!info || !info->length || !data) +if (!info || !info->length || !info->data)return -EINVAL ;if (hw->phy.link_info.module_type[0 ] ==I40E_MODULE_TYPE_SFP ) is_sfp = true; + data = info->data;for (i =0 ; i < info->length; i++) {u32 offset = i + info->offset;u32 addr = is_sfp ?I40E_I2C_EEPROM_DEV_ADDR :0 ;
Signature · 1 line
2.20.1
Thomas Monjalon
AppliedQuoted 6 lines
Bruce Richardson (5):
examples/vhost_scsi: fix header check for meson build examples/vhost_scsi: fix missing NULL-check for parameter net/i40e: fix dereference before NULL check in mbuf release app/testpmd: fix variable use before NULL check net/i40e: fix dereference before check when getting EEPROM
Applied, thanks