common/cnxk: fix uninitialized pointers in NPA context dump
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.
--- drivers/common/cnxk/roc_npa_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/common/cnxk/roc_npa_debug.c +2 -2
@@ -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
Jerin Jacob
AppliedQuoted 7 lines · Nawal Kishor
In
roc_npa_ctx_dump(), rsp andrsp_cn20kare only set throughmbox_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")Signed-off-by Nawal Kishor <[email protected]>
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@@ -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