[PATCH 15/19] common/cnxk: resolve klocwork issues
Nithin Dabilpuram
ndabilpuram at marvell.com
Mon Sep 1 09:30:31 CEST 2025
From: Rakesh Kudurumalla <rkudurumalla at marvell.com>
Fix klockwork for NULL pointer dereference
Signed-off-by: Rakesh Kudurumalla <rkudurumalla at marvell.com>
---
drivers/common/cnxk/roc_nix_queue.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index 3f11aa89fc..6e4079302b 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -112,6 +112,11 @@ roc_nix_sq_ena_dis(struct roc_nix_sq *sq, bool enable)
{
int rc = 0;
+ if (!sq) {
+ rc = NIX_ERR_PARAM;
+ goto done;
+ }
+
rc = roc_nix_tm_sq_aura_fc(sq, enable);
if (rc)
goto done;
@@ -2163,9 +2168,9 @@ nix_sqb_mem_dyn_free(uint64_t aura_handle, uint16_t count)
int
roc_nix_sq_fini(struct roc_nix_sq *sq)
{
- struct roc_nix *roc_nix = sq->roc_nix;
- bool sq_resize_ena = roc_nix->sq_resize_ena;
struct ndc_sync_op *ndc_req;
+ struct roc_nix *roc_nix;
+ bool sq_resize_ena;
struct mbox *mbox;
struct nix *nix;
uint16_t qid;
@@ -2174,6 +2179,9 @@ roc_nix_sq_fini(struct roc_nix_sq *sq)
if (sq == NULL)
return NIX_ERR_PARAM;
+ roc_nix = sq->roc_nix;
+ sq_resize_ena = roc_nix->sq_resize_ena;
+
nix = roc_nix_to_nix_priv(roc_nix);
mbox = (&nix->dev)->mbox;
@@ -2228,7 +2236,7 @@ sqb_aura_dyn_expand(struct roc_nix_sq *sq, uint16_t count)
int i;
blk_sz = nix->sqb_size;
- sqbs = calloc(1, count * sizeof(uint64_t *));
+ sqbs = calloc(1, count * sizeof(uint64_t));
if (!sqbs)
return -ENOMEM;
@@ -2300,7 +2308,7 @@ sqb_aura_dyn_contract(struct roc_nix_sq *sq, uint16_t count)
cycles = (timeout * 10 * plt_tsc_hz()) / (uint64_t)1E6;
cycles += plt_tsc_cycles();
- sqbs = calloc(1, count * sizeof(uint64_t *));
+ sqbs = calloc(1, count * sizeof(uint64_t));
if (!sqbs)
return -ENOMEM;
--
2.34.1
More information about the dev
mailing list