From 61da0fe6c46ab11aeeeb8a9bd939b98ef50eca15 Mon Sep 17 00:00:00 2001 From: Hanumanth Pothula Date: Tue, 31 May 2022 17:49:50 +0530 Subject: [PATCH] common/cnxk: add lower bound check for SSO resources 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 --- 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 358d37a9f2..d986abe573 100644 --- a/drivers/common/cnxk/roc_sso.c +++ b/drivers/common/cnxk/roc_sso.c @@ -665,9 +665,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; plt_spinlock_lock(&sso->mbox_lock); -- 2.20.1