Skip to contentSkip to conversation

common/cnxk: fix uninitialized pointers in NPA context dump

PATCH Applied Nawal Kishor 2 participants 2 messages Oct 30 – Nov 5

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/cnxk: fix uninitialized pointers in NPA context dump

In roc_npa_ctx_dump(), rsp and rsp_cn20k are only set through mbox_process_msg() in separate branches, while the dump code that reads them selects the pointer in a different branch. The compiler cannot prove that the pointer being read was set, and warns about a possibly uninitialized variable.

Initialize both pointers to NULL.

Fixes a7cc84c6e9e5 ("common/cnxk: support HALO in NPA")
---
 drivers/common/cnxk/roc_npa_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/common/cnxk/roc_npa_debug.c +2 -2
index f978be9642..e2b50ae1c3 100644
@@ -249,9 +249,9 @@ npa_cn20k_aura_dump(__io struct npa_cn20k_aura_s *aura)
 int
 roc_npa_ctx_dump(void)
 {
+	struct npa_cn20k_aq_enq_rsp *rsp_cn20k = NULL;
 	struct npa_cn20k_aq_enq_req *aq_cn20k;
-	struct npa_cn20k_aq_enq_rsp *rsp_cn20k;
-	struct npa_aq_enq_rsp *rsp;
+	struct npa_aq_enq_rsp *rsp = NULL;
 	struct npa_aq_enq_req *aq;
 	struct mbox *mbox;
 	struct npa_lf *lf;
Signature · 1 line
2.48.1
Applied
#1 lore raw
Quoted 7 lines · Nawal Kishor

In roc_npa_ctx_dump(), rsp and rsp_cn20k are only set through mbox_process_msg() in separate branches, while the dump code that reads them selects the pointer in a different branch. The compiler cannot prove that the pointer being read was set, and warns about a possibly uninitialized variable.

Quoted 5 lines

Initialize both pointers to NULL.

Fixes a7cc84c6e9e5 ("common/cnxk: support HALO in NPA")

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

Quoted 23 lines
---
 drivers/common/cnxk/roc_npa_debug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/common/cnxk/roc_npa_debug.c +2 -3
index f978be9642..e2b50ae1c3 100644
@@ -249,9 +249,9 @@ npa_cn20k_aura_dump(__io struct npa_cn20k_aura_s *aura)
 int
 roc_npa_ctx_dump(void)
 {
+       struct npa_cn20k_aq_enq_rsp *rsp_cn20k = NULL;
        struct npa_cn20k_aq_enq_req *aq_cn20k;
-       struct npa_cn20k_aq_enq_rsp *rsp_cn20k;
-       struct npa_aq_enq_rsp *rsp;
+       struct npa_aq_enq_rsp *rsp = NULL;
        struct npa_aq_enq_req *aq;
        struct mbox *mbox;
        struct npa_lf *lf;
--

2.48.1