[v3,12/32] common/cnxk: fix null pointer dereference
Checks
Commit Message
From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Fix null pointer dereferences reported by klocwork.
Fixes: 4398c4092f3d ("common/cnxk: dump inline device RQ context")
Fixes: 79dc6f324e82 ("common/cnxk: add inline function for statistics")
cc: stable@dpdk.org
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
drivers/common/cnxk/roc_nix_debug.c | 8 +++++++-
drivers/common/cnxk/roc_nix_inl_dev.c | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
@@ -733,7 +733,13 @@ roc_nix_queues_ctx_dump(struct roc_nix *roc_nix, FILE *file)
inl_rq = roc_nix_inl_dev_rq(roc_nix);
if (inl_rq) {
struct idev_cfg *idev = idev_get_cfg();
- struct nix_inl_dev *inl_dev = idev->nix_inl_dev;
+ struct nix_inl_dev *inl_dev = NULL;
+
+ if (idev && idev->nix_inl_dev)
+ inl_dev = idev->nix_inl_dev;
+
+ if (!inl_dev)
+ return -EINVAL;
rc = nix_q_ctx_get(&inl_dev->dev, NIX_AQ_CTYPE_RQ, inl_rq->qid, &ctx);
if (rc) {
@@ -843,7 +843,7 @@ roc_nix_inl_dev_stats_get(struct roc_nix_stats *stats)
if (stats == NULL)
return NIX_ERR_PARAM;
- if (!idev && idev->nix_inl_dev)
+ if (idev && idev->nix_inl_dev)
inl_dev = idev->nix_inl_dev;
if (!inl_dev)