[PATCH v2 10/16] app/pdump: verify strdup return value

Chengwen Feng fengchengwen at huawei.com
Fri Nov 10 11:01:11 CET 2023


Add verify strdup return value logic.

Fixes: caa7028276b8 ("app/pdump: add tool for packet capturing")
Cc: stable at dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
 app/pdump/main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/app/pdump/main.c b/app/pdump/main.c
index 7a1c7bdf60..a9205e130b 100644
--- a/app/pdump/main.c
+++ b/app/pdump/main.c
@@ -171,6 +171,9 @@ parse_device_id(const char *key __rte_unused, const char *value,
 	struct pdump_tuples *pt = extra_args;
 
 	pt->device_id = strdup(value);
+	if (pt->device_id == NULL)
+		return -1;
+
 	pt->dump_by_type = DEVICE_ID;
 
 	return 0;
-- 
2.17.1



More information about the dev mailing list