Skip to contentSkip to conversation

app/testpmd: fix dereference null return valiue

PATCH Applied Jasvinder Singh 2 participants 2 messages Jan 22, 2018 – Jan 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/testpmd: fix dereference null return valiue

Calloc() function might returns NULL due to insufficient space. Therefore, check for handling memory allocation failure is added.

Coverity issue: 257030

Fixes 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode")
---
 app/test-pmd/tm.c | 4 ++++
 1 file changed, 4 insertions(+)
app/test-pmd/tm.c +4 -0
index b76335c..7231552 100644
@@ -575,6 +575,10 @@ softport_tm_tc_node_add(portid_t port_id, struct tm_hierarchy *h,
 				tc_parent_node_id = h->pipe_node_id[i][j];
 				tnp.shared_shaper_id =
 					(uint32_t *)calloc(1, sizeof(uint32_t));
+				if (tnp.shared_shaper_id == NULL) {
+					printf("Shared shaper mem alloc err\n");
+					return -1;
+				}
 				tnp.shared_shaper_id[0] = k;
 				pos = j + (i * PIPE_NODES_PER_SUBPORT);
 				h->tc_node_id[pos][k] =
Signature · 1 line
2.9.3
#1 lore raw

22/01/2018 16:45, Jasvinder Singh:

Quoted 7 lines

Calloc() function might returns NULL due to insufficient space. Therefore, check for handling memory allocation failure is added.

Coverity issue: 257030

Fixes 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode")

Applied, thanks