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

Message ID 20231110100117.8350-11-fengchengwen@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series verify strdup return value |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen Nov. 10, 2023, 10:01 a.m. UTC
  Add verify strdup return value logic.

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

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

Patch

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;