* [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0
@ 2017-06-12 9:07 Yong Wang
2017-06-20 2:44 ` Wu, Jingjing
0 siblings, 1 reply; 4+ messages in thread
From: Yong Wang @ 2017-06-12 9:07 UTC (permalink / raw)
To: helin.zhang, jingjing.wu; +Cc: dev, Yong Wang
In function i40e_vsi_config_tc_queue_mapping(), if 'enabled_tcmap' is
0, 'total_tc' might be 0. Then 'total_tc' might be used in a division
by 0 in "qpnum_per_tc = i40e_align_floor(vsi->nb_qps / total_tc)". Fix
it by adding a check to parameter 'enabled_tcmap'.
Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
---
drivers/net/i40e/i40e_ethdev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index c18a93b..d41b213 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -4257,6 +4257,11 @@ enum i40e_status_code
int i, total_tc = 0;
uint16_t qpnum_per_tc, bsf, qp_idx;
+ if (enabled_tcmap == 0) {
+ PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0");
+ return I40E_ERR_PARAM;
+ }
+
ret = validate_tcmap_parameter(vsi, enabled_tcmap);
if (ret != I40E_SUCCESS)
return ret;
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0
2017-06-12 9:07 [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0 Yong Wang
@ 2017-06-20 2:44 ` Wu, Jingjing
2017-06-20 7:48 ` wang.yong19
0 siblings, 1 reply; 4+ messages in thread
From: Wu, Jingjing @ 2017-06-20 2:44 UTC (permalink / raw)
To: Yong Wang, Zhang, Helin; +Cc: dev
> -----Original Message-----
> From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> Sent: Monday, June 12, 2017 5:07 PM
> To: Zhang, Helin <helin.zhang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> Subject: [PATCH] net/i40e: fix param check to avoid division by 0
>
> In function i40e_vsi_config_tc_queue_mapping(), if 'enabled_tcmap' is
> 0, 'total_tc' might be 0. Then 'total_tc' might be used in a division
> by 0 in "qpnum_per_tc = i40e_align_floor(vsi->nb_qps / total_tc)". Fix
> it by adding a check to parameter 'enabled_tcmap'.
>
> Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> ---
> drivers/net/i40e/i40e_ethdev.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index c18a93b..d41b213 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -4257,6 +4257,11 @@ enum i40e_status_code
> int i, total_tc = 0;
> uint16_t qpnum_per_tc, bsf, qp_idx;
>
> + if (enabled_tcmap == 0) {
> + PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0");
> + return I40E_ERR_PARAM;
> + }
> +
> ret = validate_tcmap_parameter(vsi, enabled_tcmap);
> if (ret != I40E_SUCCESS)
> return ret;
> --
Thanks for the fix.
Could you add the check in func validate_tcmap_parameter?
Thanks
Jingjing
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0
2017-06-20 2:44 ` Wu, Jingjing
@ 2017-06-20 7:48 ` wang.yong19
2017-06-23 10:02 ` Wu, Jingjing
0 siblings, 1 reply; 4+ messages in thread
From: wang.yong19 @ 2017-06-20 7:48 UTC (permalink / raw)
To: Wu, Jingjing; +Cc: dev, Zhang, Helin
> RE: [PATCH] net/i40e: fix param check to avoid division by 0
>
>
>
> > -----Original Message-----
> > From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> > Sent: Monday, June 12, 2017 5:07 PM
> > To: Zhang, Helin <helin.zhang@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> > Subject: [PATCH] net/i40e: fix param check to avoid division by 0
> >
> > In function i40e_vsi_config_tc_queue_mapping(), if 'enabled_tcmap' is
> > 0, 'total_tc' might be 0. Then 'total_tc' might be used in a division
> > by 0 in "qpnum_per_tc = i40e_align_floor(vsi->nb_qps / total_tc)". Fix
> > it by adding a check to parameter 'enabled_tcmap'.
> >
> > Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> > ---
> > drivers/net/i40e/i40e_ethdev.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c
b/drivers/net/i40e/i40e_ethdev.c
> > index c18a93b..d41b213 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -4257,6 +4257,11 @@ enum i40e_status_code
> > int i, total_tc = 0;
> > uint16_t qpnum_per_tc, bsf, qp_idx;
> >
> > + if (enabled_tcmap == 0) {
> > + PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0");
> > + return I40E_ERR_PARAM;
> > + }
> > +
> > ret = validate_tcmap_parameter(vsi, enabled_tcmap);
> > if (ret != I40E_SUCCESS)
> > return ret;
> > --
> Thanks for the fix.
>
> Could you add the check in func validate_tcmap_parameter?
>
> Thanks
> Jingjing
>
>
Since func validate_tcmap_parameter() was called by 3 func, if I add
the check to func validate_tcmap_parameter(), I am not sure whether it
will impact the other two callers who didn't meet division by 0.
Or should I fix it by changing 'total_tc' from 0 to 1 just as func
i40e_vsi_update_queue_mapping() does?
Thanks
Yong
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0
2017-06-20 7:48 ` wang.yong19
@ 2017-06-23 10:02 ` Wu, Jingjing
0 siblings, 0 replies; 4+ messages in thread
From: Wu, Jingjing @ 2017-06-23 10:02 UTC (permalink / raw)
To: wang.yong19; +Cc: dev, Zhang, Helin
From: wang.yong19@zte.com.cn [mailto:wang.yong19@zte.com.cn]
Sent: Tuesday, June 20, 2017 3:48 PM
To: Wu, Jingjing <jingjing.wu@intel.com>
Cc: dev@dpdk.org; Zhang, Helin <helin.zhang@intel.com>
Subject: RE: [PATCH] net/i40e: fix param check to avoid division by 0
> RE: [PATCH] net/i40e: fix param check to avoid division by 0
>
>
>
> > -----Original Message-----
> > From: Yong Wang [mailto:wang.yong19@zte.com.cn]
> > Sent: Monday, June 12, 2017 5:07 PM
> > To: Zhang, Helin <helin.zhang@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>
> > Cc: dev@dpdk.org; Yong Wang <wang.yong19@zte.com.cn>
> > Subject: [PATCH] net/i40e: fix param check to avoid division by 0
> >
> > In function i40e_vsi_config_tc_queue_mapping(), if 'enabled_tcmap' is
> > 0, 'total_tc' might be 0. Then 'total_tc' might be used in a division
> > by 0 in "qpnum_per_tc = i40e_align_floor(vsi->nb_qps / total_tc)". Fix
> > it by adding a check to parameter 'enabled_tcmap'.
> >
> > Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
> > ---
> > drivers/net/i40e/i40e_ethdev.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> > index c18a93b..d41b213 100644
> > --- a/drivers/net/i40e/i40e_ethdev.c
> > +++ b/drivers/net/i40e/i40e_ethdev.c
> > @@ -4257,6 +4257,11 @@ enum i40e_status_code
> > int i, total_tc = 0;
> > uint16_t qpnum_per_tc, bsf, qp_idx;
> >
> > + if (enabled_tcmap == 0) {
> > + PMD_DRV_LOG(ERR, "Error! enabled tcmap shouldn't be 0");
> > + return I40E_ERR_PARAM;
> > + }
> > +
> > ret = validate_tcmap_parameter(vsi, enabled_tcmap);
> > if (ret != I40E_SUCCESS)
> > return ret;
> > --
> Thanks for the fix.
>
> Could you add the check in func validate_tcmap_parameter?
>
> Thanks
> Jingjing
>
>
Since func validate_tcmap_parameter() was called by 3 func, if I add
the check to func validate_tcmap_parameter(), I am not sure whether it
will impact the other two callers who didn't meet division by 0.
Or should I fix it by changing 'total_tc' from 0 to 1 just as func
i40e_vsi_update_queue_mapping() does?
Thanks, that would be better. Because other caller is used for default
TC map, which is 1.
Thanks
Jingjing
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-23 10:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-12 9:07 [dpdk-dev] [PATCH] net/i40e: fix param check to avoid division by 0 Yong Wang
2017-06-20 2:44 ` Wu, Jingjing
2017-06-20 7:48 ` wang.yong19
2017-06-23 10:02 ` Wu, Jingjing
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).