common/cnxk: add lower bound check for SSO resources

Message ID 20220531121950.3511727-1-hpothula@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series common/cnxk: add lower bound check for SSO resources |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-testing warning apply patch failure
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Hanumanth Pothula May 31, 2022, 12:19 p.m. UTC
  Observing a crash when the user runs the second test case, with the
first test case using all HWGRP and HWS, SSO resources. This happens
as there are no HWGRP and HWS resources left for the second test case.

Make sure to process a test case only when valid HWGRPS and HWS
are present by adding lower bound check for HWGRPS and HWS.

Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>
---
 drivers/common/cnxk/roc_sso.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Jerin Jacob June 10, 2022, 9:28 a.m. UTC | #1
On Tue, May 31, 2022 at 5:50 PM Hanumanth Pothula <hpothula@marvell.com> wrote:
>
> Observing a crash when the user runs the second test case, with the
> first test case using all HWGRP and HWS, SSO resources. This happens
> as there are no HWGRP and HWS resources left for the second test case.
>
> Make sure to process a test case only when valid HWGRPS and HWS
> are present by adding lower bound check for HWGRPS and HWS.
>
> Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>

Applied to dpdk-next-net-eventdev/for-main. Thanks

> ---
>  drivers/common/cnxk/roc_sso.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
> index f8a0a96533..8997e6f999 100644
> --- a/drivers/common/cnxk/roc_sso.c
> +++ b/drivers/common/cnxk/roc_sso.c
> @@ -598,9 +598,9 @@ roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp)
>         struct sso_lf_alloc_rsp *rsp_hwgrp;
>         int rc;
>
> -       if (roc_sso->max_hwgrp < nb_hwgrp)
> +       if (!nb_hwgrp || roc_sso->max_hwgrp < nb_hwgrp)
>                 return -ENOENT;
> -       if (roc_sso->max_hws < nb_hws)
> +       if (!nb_hws || roc_sso->max_hws < nb_hws)
>                 return -ENOENT;
>
>         rc = sso_rsrc_attach(roc_sso, SSO_LF_TYPE_HWS, nb_hws);
> --
> 2.25.1
>
  

Patch

diff --git a/drivers/common/cnxk/roc_sso.c b/drivers/common/cnxk/roc_sso.c
index f8a0a96533..8997e6f999 100644
--- a/drivers/common/cnxk/roc_sso.c
+++ b/drivers/common/cnxk/roc_sso.c
@@ -598,9 +598,9 @@  roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp)
 	struct sso_lf_alloc_rsp *rsp_hwgrp;
 	int rc;
 
-	if (roc_sso->max_hwgrp < nb_hwgrp)
+	if (!nb_hwgrp || roc_sso->max_hwgrp < nb_hwgrp)
 		return -ENOENT;
-	if (roc_sso->max_hws < nb_hws)
+	if (!nb_hws || roc_sso->max_hws < nb_hws)
 		return -ENOENT;
 
 	rc = sso_rsrc_attach(roc_sso, SSO_LF_TYPE_HWS, nb_hws);