fixes for clean code
Subsystems (5)
cover fixes for clean code
This patchset fix some bugs, to make the code more clean.
Chengchang Tang (1):
net/bonding: fix configuration assignment overflow
HongBo Zheng (5):
app/test: add NULL pointer check of memory allocation lib/librte_pipeline: fix the use of unsafe strcpy examples/l3fwd: add function return value check crypto/virtio: fix return values check error net/e1000: add function return value check
Min Hu (Connor) (4):
net/pfe: check return value
common/sfc_efx/base: delete redundant handling
bus/dpaa: fix management command init calling
app/regex: fix division by zero
app/test-regex/main.c | 8 +++++--- app/test/test_crc.c | 2 ++ drivers/bus/dpaa/base/qbman/bman.c | 6 ++---- drivers/common/sfc_efx/base/rhead_nic.c | 3 +-- drivers/crypto/virtio/virtio_rxtx.c | 4 ++-- drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +- drivers/net/e1000/base/e1000_ich8lan.c | 2 ++ drivers/net/pfe/pfe_ethdev.c | 6 ++++++ examples/l3fwd/l3fwd_event.c | 6 +++++- lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- 10 files changed, 28 insertions(+), 15 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/10 net/pfe: check return value
Variable 'fd', which may receive negative value when open "/dev/mem" file.
This patch added checking return value process.
--- drivers/net/pfe/pfe_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/pfe/pfe_ethdev.c +6 -0
@@ -1049,6 +1049,12 @@ pmd_pfe_probe(struct rte_vdev_device *vdev) g_pfe->cbus_size = cbus_size; fd =open ("/dev/mem" ,O_RDWR ); +if (fd <0 ) { +PFE_PMD_ERR ("Can not open /dev/mem" ); + rc = -EIO ; + goto err; + } + g_pfe->cbus_baseaddr =mmap (NULL , cbus_size,PROT_READ |PROT_WRITE ,MAP_SHARED , fd, cbus_addr);close (fd);
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 01/10] net/pfe: check return value
drivers/net/pfe/pfe_ethdev.c pmd_pfe_probe(struct rte_vdev_device *vdev) · line 1057
Quoted 8 lines · On Mon, 19 Apr 2021 21:34:40 +0800 "Min Hu (Connor)" <[email protected]> wrote:
drivers/net/pfe/pfe_ethdev.c +6
-0fd =open ("/dev/mem" ,O_RDWR ); +if (fd <0 ) { +PFE_PMD_ERR ("Can not open /dev/mem" ); + rc = -EIO ; + goto err; + } +
This patch makes sense and should be applied.
But the errno is most like EPERM so maybe:
rc = -errno;
PS: /dev/mem is a bad idea, Linux kernel config often disables it in distributions. Not sure why this driver can't use UIO or VFIO like normal devices. This should have been caught during code review.
PATCH 2/10 common/sfc_efx/base: delete redundant handling
In reply to Min Hu (Connor)the default case in 'rhead_nic_get_bar_region' is unreachable.
This patch fixed that.
--- drivers/common/sfc_efx/base/rhead_nic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/common/sfc_efx/base/rhead_nic.c +1 -2
@@ -483,8 +483,7 @@ rhead_nic_get_bar_region(break ;default : - rc =EINVAL ; - goto fail1; +break ; }return (0 );
Signature · 1 line
2.7.4
Andrew Rybchenko
NAKRe: [dpdk-dev] [PATCH 02/10] common/sfc_efx/base: delete redundant handling
Quoted 1 line · Min Hu (Connor)
the default case in '
rhead_nic_get_bar_region' is unreachable.
Why? May be it is true right now, but default case is required to handle future changes in enum and missing update here.
Quoted 7 lines
This patch fixed that.
Fixes 3c1c5cc4a786 ("common/sfc_efx/base: add Riverhead support to NIC module")Signed-off-by Min Hu (Connor) <[email protected]>
Nack
Quoted 19 lines
--- drivers/common/sfc_efx/base/rhead_nic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/common/sfc_efx/base/rhead_nic.c +1
-2@@ -483,8 +483,7 @@ rhead_nic_get_bar_region(break ;default : - rc =EINVAL ; - goto fail1; +break ; }return (0 );
Re: [dpdk-dev] [PATCH 02/10] common/sfc_efx/base: delete redundant handling
Quoted 6 lines · Andrew Rybchenko
Quoted 1 line · Min Hu (Connor)
the default case in '
rhead_nic_get_bar_region' is unreachable.Why? May be it is true right now, but default case is required to handle future changes in enum and missing update here.
Well, agreed, this patch can be abandoned.
Quoted 32 lines
Quoted 7 lines
This patch fixed that.
Fixes 3c1c5cc4a786 ("common/sfc_efx/base: add Riverhead support to NIC module")Signed-off-by Min Hu (Connor) <[email protected]>Nack
Quoted 10 lines
--- drivers/common/sfc_efx/base/rhead_nic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/common/sfc_efx/base/rhead_nic.c +0
-0drivers/common/sfc_efx/base/rhead_nic.c rhead_nic_get_bar_region( · line 489
Quoted 9 lines
drivers/common/sfc_efx/base/rhead_nic.c +1
-2@@ -483,8 +483,7 @@ rhead_nic_get_bar_region(break ;default : - rc =EINVAL ; - goto fail1; +break ; }return (0 );.
PATCH 3/10 bus/dpaa: fix management command init calling
In reply to Min Hu (Connor)'bm_mc_init' only return 0, but the function whicl calls int check the negative ret, and this is redundant.
This patch fixed it by not checking the return value.
--- drivers/bus/dpaa/base/qbman/bman.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/bus/dpaa/base/qbman/bman.c +2 -4
@@ -70,10 +70,8 @@ struct bman_portal *bman_create_portal(struct bman_portal *portal,pr_err ("Bman RCR initialisation failed\n" );return NULL ; } -if (bm_mc_init (p)) { -pr_err ("Bman MC initialisation failed\n" ); - goto fail_mc; - } + (void )bm_mc_init (p); + portal->pools =kmalloc (2 *sizeof (*pools),GFP_KERNEL );if (!portal->pools) goto fail_pools;
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 03/10] bus/dpaa: fix management command init calling
Quoted 18 lines · Min Hu (Connor)
'
bm_mc_init' only return 0, but the function whicl calls int check the negative ret, and this is redundant.This patch fixed it by not checking the return value.
Fixes f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")Signed-off-by Min Hu (Connor) <[email protected]>--- drivers/bus/dpaa/base/qbman/bman.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/bus/dpaa/base/qbman/bman.c +0
-0
drivers/bus/dpaa/base/qbman/bman.c struct bman_portal *bman_create_portal(struct bman_portal *portal, · line 74
Quoted 9 lines
drivers/bus/dpaa/base/qbman/bman.c +2
-4@@ -70,10 +70,8 @@ struct bman_portal *bman_create_portal(struct bman_portal *portal,pr_err ("Bman RCR initialisation failed\n" );return NULL ; } -if (bm_mc_init (p)) { -pr_err ("Bman MC initialisation failed\n" ); - goto fail_mc; - } + (void )bm_mc_init (p); +
As I understand compiler can do it for you and there is no point to break the code in the case of future changes if bm_mc_init() starts to return errors.
Quoted 4 lines
drivers/bus/dpaa/base/qbman/bman.c +0
-0portal->pools =kmalloc (2 *sizeof (*pools),GFP_KERNEL );if (!portal->pools) goto fail_pools;
Re: [dpdk-dev] [PATCH 03/10] bus/dpaa: fix management command init calling
Quoted 24 lines · Andrew Rybchenko
Quoted 23 lines · Min Hu (Connor)
'
bm_mc_init' only return 0, but the function whicl calls int check the negative ret, and this is redundant.This patch fixed it by not checking the return value.
Fixes f38f61e982f8 ("bus/dpaa: add BMAN hardware interfaces")Signed-off-by Min Hu (Connor) <[email protected]>--- drivers/bus/dpaa/base/qbman/bman.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/bus/dpaa/base/qbman/bman.c +0
-2@@ -70,10 +70,8 @@ struct bman_portal *bman_create_portal(struct bman_portal *portal,pr_err ("Bman RCR initialisation failed\n" );return NULL ; } -if (bm_mc_init (p)) { -pr_err ("Bman MC initialisation failed\n" );
Quoted 9 lines
drivers/bus/dpaa/base/qbman/bman.c struct bman_portal *bman_create_portal(struct bman_portal *portal, · line 74
Quoted 4 lines
drivers/bus/dpaa/base/qbman/bman.c +2
-2- goto fail_mc; - } + (void )bm_mc_init (p); +As I understand compiler can do it for you and there is no point to break the code in the case of future changes if
bm_mc_init()starts to return errors.
Agreed, this patch can be abandoned.
Quoted 7 lines
drivers/bus/dpaa/base/qbman/bman.c struct bman_portal *bman_create_portal(struct bman_portal *portal, · line 77
Quoted 4 lines
drivers/bus/dpaa/base/qbman/bman.c +0
-0portal->pools =kmalloc (2 *sizeof (*pools),GFP_KERNEL );if (!portal->pools) goto fail_pools;.
PATCH 4/10 app/regex: fix division by zero
In reply to Min Hu (Connor)Variable nb_jobs, which may be zero, is used as a denominator.
This patch fixed it.
--- app/test-regex/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
app/test-regex/main.c +5 -3
@@ -725,9 +725,11 @@ main(int argc, char **argv)if (data_len <=0 )rte_exit (EXIT_FAILURE ,"Error, can't read file, or file is empty.\n" ); - job_len = data_len / nb_jobs; -if (job_len ==0 ) -rte_exit (EXIT_FAILURE ,"Error, To many jobs, for the given input.\n" ); +if (!nb_jobs) { + job_len = data_len / nb_jobs; +if (job_len ==0 ) +rte_exit (EXIT_FAILURE ,"Error, To many jobs, for the given input.\n" ); + }if (job_len > nb_max_payload)rte_exit (EXIT_FAILURE ,"Error, not enough jobs to cover input.\n" );
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 04/10] app/regex: fix division by zero
Hi Min,
Quoted 39 lines
-----Original Message-----
From: Min Hu (Connor) <[email protected]>
Sent: Monday, April 19, 2021 4:35 PM
Subject: [PATCH 04/10] app/regex: fix division by zeroVariable
nb_jobs, which may be zero, is used as a denominator.This patch fixed it.
Fixes f5cffb7eb7fb ("app/regex: read data file once at startup")Signed-off-by Min Hu (Connor) <[email protected]>--- app/test-regex/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)app/test-regex/main.c +5
-3@@ -725,9 +725,11 @@ main(int argc, char **argv)if (data_len <=0 ) rte_exit(EXIT_FAILURE, "Error, can't read file, or file is empty.\n"); - job_len = data_len / nb_jobs; -if (job_len ==0 ) - rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given input.\n"); +if (!nb_jobs) { + job_len = data_len / nb_jobs; +if (job_len ==0 ) + rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given input.\n"); + }app/test-regex/main.c +0
-0if (job_len > nb_max_payload) rte_exit(EXIT_FAILURE, "Error, not enough jobs to cover
Quoted 3 lines
input.\n");
--
2.7.4
Thanks,
Ori
PATCH 5/10 app/test: add null pointer check of memory allocation
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
The rte_zmalloc is called in test_crc_calc without null pointer check. This patch adds null pointer checks on return value of rte_zmalloc.
--- app/test/test_crc.c | 2 ++ 1 file changed, 2 insertions(+)
app/test/test_crc.c +2 -0
@@ -80,6 +80,8 @@ test_crc_calc(void)/* 32-bit ethernet CRC: Test 2 */ test_data =rte_zmalloc (NULL ,CRC32_VEC_LEN1 ,0 ); +if (test_data ==NULL ) +return -7 ;for (i =0 ; i <CRC32_VEC_LEN1 ; i +=12 )rte_memcpy (&test_data[i], crc32_vec1,12 );
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 05/10] app/test: add null pointer check of memory allocation
19/04/2021 15:34, Min Hu (Connor):
Quoted 11 lines
From: HongBo Zheng <[email protected]>
The
rte_zmallocis called intest_crc_calcwithout null pointer check. This patch adds null pointer checks on return value ofrte_zmalloc.Fixes 9c77b848b1c1 ("test: add CRC computation")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
Applied only this patch, thanks.
PATCH 6/10 lib/librte_pipeline: fix the use of unsafe strcpy
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
'strcpy' is called in rte_swx_ctl_table_info_get, this function is unsafe, use 'strncpy' instead.
--- lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_pipeline/rte_swx_pipeline.c +2 -2
@@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,if (!t)return -EINVAL ; -strcpy (table->name, t->name); -strcpy (table->args, t->args); +strncpy (table->name, t->name,RTE_SWX_CTL_NAME_SIZE ); +strncpy (table->args, t->args,RTE_SWX_CTL_NAME_SIZE ); table->n_match_fields = t->n_fields; table->n_actions = t->n_actions; table->default_action_is_const = t->default_action_is_const;
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy
Quoted 19 lines · Min Hu (Connor)
From: HongBo Zheng <[email protected]>
'strcpy' is called in
rte_swx_ctl_table_info_get, this function is unsafe, use 'strncpy' instead.Fixes 393b96e2aa2a ("pipeline: add SWX pipeline query API")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_pipeline/rte_swx_pipeline.c +0
-0
lib/librte_pipeline/rte_swx_pipeline.c rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p, · line 9451
Quoted 7 lines
lib/librte_pipeline/rte_swx_pipeline.c +2
-2@@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,if (!t)return -EINVAL ; -strcpy (table->name, t->name); -strcpy (table->args, t->args); +strncpy (table->name, t->name,RTE_SWX_CTL_NAME_SIZE ); +strncpy (table->args, t->args,RTE_SWX_CTL_NAME_SIZE );
strlcpy() should be used in fact, since strncpy() has problems as well.
Quoted 4 lines
lib/librte_pipeline/rte_swx_pipeline.c +0
-0table->n_match_fields = t->n_fields; table->n_actions = t->n_actions; table->default_action_is_const = t->default_action_is_const;
Re: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy
In reply to Min Hu (Connor)Quoted 19 lines · On Mon, 19 Apr 2021 21:34:45 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: HongBo Zheng <[email protected]>
'strcpy' is called in
rte_swx_ctl_table_info_get, this function is unsafe, use 'strncpy' instead.Fixes 393b96e2aa2a ("pipeline: add SWX pipeline query API")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/librte_pipeline/rte_swx_pipeline.c +0
-0
lib/librte_pipeline/rte_swx_pipeline.c rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p, · line 9454
Quoted 10 lines
lib/librte_pipeline/rte_swx_pipeline.c +2
-2@@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p,if (!t)return -EINVAL ; -strcpy (table->name, t->name); -strcpy (table->args, t->args); +strncpy (table->name, t->name,RTE_SWX_CTL_NAME_SIZE ); +strncpy (table->args, t->args,RTE_SWX_CTL_NAME_SIZE ); table->n_match_fields = t->n_fields; table->n_actions = t->n_actions; table->default_action_is_const = t->default_action_is_const;
This patch is unnecessary.
Both structures declare the same size for the name and args. Therefore the strcpy is always safe as long as the table structure is correctly setup with null terminated string. If not there are worse bugs.
RE: [dpdk-dev] [PATCH 06/10] lib/librte_pipeline: fix the use of unsafe strcpy
Quoted 40 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, June 30, 2023 7:09 PM
To: Min Hu (Connor) <[email protected]>
Cc: [email protected]; [email protected]; Dumitrescu, Cristian <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH 06/10]lib/librte_pipeline: fix the use of unsafe strcpyQuoted 8 lines · On Mon, 19 Apr 2021 21:34:45 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: HongBo Zheng <[email protected]>
'strcpy' is called in
rte_swx_ctl_table_info_get, this function is unsafe, use 'strncpy' instead.Fixes 393b96e2aa2a ("pipeline: add SWX pipeline query API")Review
Quoted 7 lines
Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- lib/librte_pipeline/rte_swx_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/lib/librte_pipeline/rte_swx_pipeline.clib/librte_pipeline/rte_swx_pipeline.c rte_swx_ctl_table_info_get(struct rte_swx_pipeline
Quoted 4 lines
index 4455d91..d4db4dd 100644
lib/librte_pipeline/rte_swx_pipeline.c +0
-0@@ -9447,8 +9447,8 @@ rte_swx_ctl_table_info_get(struct rte_swx_pipeline*p,
Quoted 3 lines
lib/librte_pipeline/rte_swx_pipeline.c +0
-0if (!t)return -EINVAL ;
Quoted 12 lines
lib/librte_pipeline/rte_swx_pipeline.c rte_swx_ctl_table_info_get(struct rte_swx_pipeline *p, · line 9454
Quoted 7 lines
lib/librte_pipeline/rte_swx_pipeline.c +2
-2-strcpy (table->name, t->name); -strcpy (table->args, t->args); +strncpy (table->name, t->name,RTE_SWX_CTL_NAME_SIZE ); +strncpy (table->args, t->args,RTE_SWX_CTL_NAME_SIZE ); table->n_match_fields = t->n_fields; table->n_actions = t->n_actions; table->default_action_is_const = t->default_action_is_const;This patch is unnecessary.
Both structures declare the same size for the name and args. Therefore the strcpy is always safe as long as the table structure is correctly setup with null terminated string. If not there are worse bugs.
+1
Agree with Steve, this is not necessary here.
PATCH 7/10 examples/l3fwd: add function return value check
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
Return value of a function 'rte_eth_macaddr_get' called at l3fwd_eth_dev_port_setup is not checked, but it is usually checked for this function.
This patch fix this problem.
--- examples/l3fwd/l3fwd_event.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
examples/l3fwd/l3fwd_event.c +5 -1
@@ -105,7 +105,11 @@ l3fwd_eth_dev_port_setup(struct rte_eth_conf *port_conf)"Cannot adjust number of descriptors: err=%d, " "port=%d\n", ret, port_id); -rte_eth_macaddr_get (port_id, &ports_eth_addr[port_id]); + ret =rte_eth_macaddr_get (port_id, &ports_eth_addr[port_id]); +if (ret <0 ) +rte_exit (EXIT_FAILURE , +"Cannot get MAC address: err=%d, port=%d\n" , + ret, port_id);print_ethaddr (" Address:" , &ports_eth_addr[port_id]);printf (", " ); print_ethaddr("Destination:",
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 07/10] examples/l3fwd: add function return value check
Quoted 6 lines · On Mon, 19 Apr 2021 21:34:46 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: HongBo Zheng <[email protected]>
Return value of a function '
rte_eth_macaddr_get' called atl3fwd_eth_dev_port_setupis not checked, but it is usually checked for this function.
Quoted 7 lines
This patch fix this problem.
Fixes a65bf3d724df ("examples/l3fwd: add ethdev setup based on eventdev")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
This looks correct, but only a buggy driver would never set macaddr.
PATCH 8/10 crypto/virtio: fix return values check error
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
In virtio_crypto_pkt_tx_burst, we check the return values of virtqueue_crypto_enqueue_xmit, which may returns -ENOSPC/-EMSGSIZE, but we only check ENOSPC/EMSGSIZE, and cause the result of checks is always false.
This patch fix this problem.
--- drivers/crypto/virtio/virtio_rxtx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/virtio/virtio_rxtx.c +2 -2
@@ -500,10 +500,10 @@ virtio_crypto_pkt_tx_burst(void *tx_queue, struct rte_crypto_op **tx_pkts,/* Enqueue Packet buffers */ error =virtqueue_crypto_enqueue_xmit (txvq, tx_pkts[nb_tx]);if (unlikely (error)) { -if (error ==ENOSPC ) +if (error == -ENOSPC )VIRTIO_CRYPTO_TX_LOG_ERR ("virtqueue_enqueue Free count = 0" ); -else if (error ==EMSGSIZE ) +else if (error == -EMSGSIZE )VIRTIO_CRYPTO_TX_LOG_ERR ("virtqueue_enqueue Free count < 1" );else
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 08/10] crypto/virtio: fix return values check error
Quoted 7 lines · On Mon, 19 Apr 2021 21:34:47 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: HongBo Zheng <[email protected]>
In
virtio_crypto_pkt_tx_burst, we check the return values ofvirtqueue_crypto_enqueue_xmit, which may returns -ENOSPC/-EMSGSIZE, but we only check ENOSPC/EMSGSIZE, and cause the result of checks is always false.
Quoted 7 lines
This patch fix this problem.
Fixes 82adb12a1fce ("crypto/virtio: support burst enqueue/dequeue")Signed-off-by HongBo Zheng <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
This patch looks correct.
PATCH 9/10 net/e1000: add function return value check
In reply to Min Hu (Connor)From: HongBo Zheng <[email protected]>
Return value of a function 'e1000_phy_has_link_generic' called at e1000_kmrn_lock_loss_workaround_ich8lan is not checked, but it is usually checked for this function.
This patch fix this problem.
--- drivers/net/e1000/base/e1000_ich8lan.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/e1000/base/e1000_ich8lan.c +2 -0
@@ -5406,6 +5406,8 @@ STATIC s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw)* stability */ ret_val =e1000_phy_has_link_generic (hw,1 ,0 , &link); +if (ret_val) +return ret_val;if (!link)return E1000_SUCCESS ;
Signature · 1 line
2.7.4
PATCH 10/10 net/bonding: fix configuration assignment overflow
In reply to Min Hu (Connor)From: Chengchang Tang <[email protected]>
The expression may cause an overflow.
This patch fix the codeDEX static check warning "INTEGER_OVERFLOW".
--- drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/rte_eth_bond_8023ad.c +1 -1
@@ -1237,7 +1237,7 @@ bond_mode_8023ad_conf_assign(struct mode8023ad_private *mode4, mode4->aggregate_wait_timeout = conf->aggregate_wait_timeout_ms * ms_ticks; mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks; mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks; - mode4->update_timeout_us = conf->update_timeout_ms *1000 ; + mode4->update_timeout_us = (uint64_t )conf->update_timeout_ms *1000 ; mode4->dedicated_queues.enabled =0 ; mode4->dedicated_queues.rx_qid =UINT16_MAX ;
Signature · 1 line
2.7.4
Re: [dpdk-dev] [PATCH 10/10] net/bonding: fix configuration assignment overflow
Quoted 4 lines · On Mon, 19 Apr 2021 21:34:49 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: Chengchang Tang <[email protected]>
The expression may cause an overflow.
Quoted 8 lines
This patch fix the codeDEX static check warning "
INTEGER_OVERFLOW".Fixes 46fb43683679 ("bond: add mode 4")Signed-off-by Chengchang Tang <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>---
Is the codeDEX static checker publicly available?
Would be good to add to CI infrastructure.
Re: [dpdk-dev] [PATCH 10/10] net/bonding: fix configuration assignment overflow
In reply to Min Hu (Connor)Quoted 11 lines · On Mon, 19 Apr 2021 21:34:49 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: Chengchang Tang <[email protected]>
The expression may cause an overflow.
This patch fix the codeDEX static check warning "
INTEGER_OVERFLOW".Fixes 46fb43683679 ("bond: add mode 4")Signed-off-by Chengchang Tang <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>
Several of these patches in this set have been applied.
But the rest need to be resubmitted and the CI test failures need to be fixed.
Re: [dpdk-dev] [PATCH 10/10] net/bonding: fix configuration assignment overflow
Hi Stephen,
Thanks for your review this series again.
Quoted 9 lines · Stephen Hemminger
Quoted 6 lines · On Mon, 19 Apr 2021 21:34:49 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: Chengchang Tang <[email protected]>
The expression may cause an overflow.
This patch fix the codeDEX static check warning "
INTEGER_OVERFLOW".
Quoted 7 lines
Quoted 5 lines
Fixes 46fb43683679 ("bond: add mode 4")Signed-off-by Chengchang Tang <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>Several of these patches in this set have been applied.
But the rest need to be resubmitted and the CI test failures need to be fixed.
Can you past a link or log about the CI test failures so as to fix it?
Quoted 1 line
.
Re: [dpdk-dev] [PATCH 10/10] net/bonding: fix configuration assignment overflow
In reply to Min Hu (Connor)Quoted 20 lines · On Mon, 19 Apr 2021 21:34:49 +0800 "Min Hu (Connor)" <[email protected]> wrote:
From: Chengchang Tang <[email protected]>
The expression may cause an overflow.
This patch fix the codeDEX static check warning "
INTEGER_OVERFLOW".Fixes 46fb43683679 ("bond: add mode 4")Signed-off-by Chengchang Tang <[email protected]>Signed-off-by Min Hu (Connor) <[email protected]>--- drivers/net/bonding/rte_eth_bond_8023ad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bonding/rte_eth_bond_8023ad.c +0
-0
drivers/net/bonding/rte_eth_bond_8023ad.c bond_mode_8023ad_conf_assign(struct mode8023ad_private *mode4, · line 1240
Quoted 5 lines
drivers/net/bonding/rte_eth_bond_8023ad.c +1
-1@@ -1237,7 +1237,7 @@ bond_mode_8023ad_conf_assign(struct mode8023ad_private *mode4, mode4->aggregate_wait_timeout = conf->aggregate_wait_timeout_ms * ms_ticks; mode4->tx_period_timeout = conf->tx_period_ms * ms_ticks; mode4->rx_marker_timeout = conf->rx_marker_period_ms * ms_ticks; - mode4->update_timeout_us = conf->update_timeout_ms *1000 ; + mode4->update_timeout_us = (uint64_t )conf->update_timeout_ms *1000 ;
It could overflow, but that would only happen if the timeout_ms was greater than 2^32 / 1000 which is 4295 seconds! The default is 100 ms.
The driver should do some more validation in bond_8023ad_setup_validate(). It does check that update_timeout_ms is non zero, but it has no upper bound.