* [PATCH 00/16] verify strdup return value
@ 2023-11-10 6:36 Chengwen Feng
2023-11-10 6:36 ` [PATCH 01/16] eal: " Chengwen Feng
` (15 more replies)
0 siblings, 16 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev
This patchset mainly fix the return value of strdup not checked which
may lead to segment fault. It also include two commits which fix memory
leak of strdup.
Chengwen Feng (16):
eal: verify strdup return value
bus/dpaa: verify strdup return value
bus/fslmc: verify strdup return value
bus/vdev: verify strdup return value
dma/idxd: verify strdup return value
event/cnxk: verify strdup return value
net/failsafe: fix memory leak when parse args
net/nfp: verify strdup return value
app/dumpcap: verify strdup return value
app/pdump: verify strdup return value
app/test: verify strdup return value
app/test-crypto-perf: verify strdup return value
app/test-dma-perf: verify strdup return value
app/testpmd: verify strdup return value
examples/qos_sched: fix memory leak when parse args
examples/vhost: verify strdup return value
app/dumpcap/main.c | 5 ++++
app/pdump/main.c | 3 +++
app/test-crypto-perf/cperf_options_parsing.c | 4 ++++
app/test-dma-perf/main.c | 2 ++
app/test-pmd/cmdline.c | 2 ++
app/test/process.h | 5 +++-
drivers/bus/dpaa/dpaa_bus.c | 4 ++++
drivers/bus/fslmc/fslmc_bus.c | 4 ++++
drivers/bus/vdev/vdev.c | 4 ++++
drivers/dma/idxd/idxd_bus.c | 10 ++++++--
drivers/event/cnxk/cnxk_eventdev.c | 3 +++
drivers/net/failsafe/failsafe_args.c | 2 +-
drivers/net/nfp/nfp_ipsec.c | 5 ++++
examples/qos_sched/args.c | 4 +++-
examples/vhost/main.c | 3 +++
lib/eal/common/eal_common_options.c | 24 ++++++++++++++++++--
lib/eal/linux/eal_dev.c | 3 +++
17 files changed, 80 insertions(+), 7 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/16] eal: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 02/16] bus/dpaa: " Chengwen Feng
` (14 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Bruce Richardson, Ciara Power, Keith Wiles,
Jianfeng Tan, Jeff Guo
Cc: dev
Add verify strdup() return value logic.
Fixes: 293c53d8b23c ("eal: add telemetry callbacks")
Fixes: 0d0f478d0483 ("eal/linux: add uevent parse and process")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
lib/eal/common/eal_common_options.c | 24 ++++++++++++++++++++++--
lib/eal/linux/eal_dev.c | 3 +++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
index a6d21f1cba..8b5a4632dd 100644
--- a/lib/eal/common/eal_common_options.c
+++ b/lib/eal/common/eal_common_options.c
@@ -226,6 +226,8 @@ eal_save_args(int argc, char **argv)
if (strcmp(argv[i], "--") == 0)
break;
eal_args[i] = strdup(argv[i]);
+ if (eal_args[i] == NULL)
+ goto error;
}
eal_args[i++] = NULL; /* always finish with NULL */
@@ -235,13 +237,31 @@ eal_save_args(int argc, char **argv)
eal_app_args = calloc(argc - i + 1, sizeof(*eal_args));
if (eal_app_args == NULL)
- return -1;
+ goto error;
- for (j = 0; i < argc; j++, i++)
+ for (j = 0; i < argc; j++, i++) {
eal_app_args[j] = strdup(argv[i]);
+ if (eal_app_args[j] == NULL)
+ goto error;
+ }
eal_app_args[j] = NULL;
return 0;
+
+error:
+ if (eal_app_args != NULL) {
+ i = 0;
+ while (eal_app_args[i] != NULL)
+ free(eal_app_args[i++]);
+ free(eal_app_args);
+ eal_app_args = NULL;
+ }
+ i = 0;
+ while (eal_args[i] != NULL)
+ free(eal_args[i++]);
+ free(eal_args);
+ eal_args = NULL;
+ return -1;
}
#endif
diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c
index ac76f6174d..df3cd6b39a 100644
--- a/lib/eal/linux/eal_dev.c
+++ b/lib/eal/linux/eal_dev.c
@@ -181,7 +181,10 @@ dev_uev_parse(const char *buf, struct rte_dev_event *event, int length)
buf += 14;
i += 14;
strlcpy(pci_slot_name, buf, sizeof(subsystem));
+ free(event->devname);
event->devname = strdup(pci_slot_name);
+ if (event->devname == NULL)
+ return -1;
}
for (; i < length; i++) {
if (*buf == '\0')
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 02/16] bus/dpaa: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
2023-11-10 6:36 ` [PATCH 01/16] eal: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 03/16] bus/fslmc: " Chengwen Feng
` (13 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Hemant Agrawal, Sachin Saxena, Shreyansh Jain; +Cc: dev
Add verify strdup return value logic.
Fixes: e79df833d3f6 ("bus/dpaa: support hotplug ops")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/bus/dpaa/dpaa_bus.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index e57159f5d8..a67f5c9ab5 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -791,6 +791,10 @@ dpaa_bus_dev_iterate(const void *start, const char *str,
/* Now that name=device_name format is available, split */
dup = strdup(str);
+ if (dup == NULL) {
+ DPAA_BUS_DEBUG("Dup string (%s) failed!\n", str);
+ return NULL;
+ }
dev_name = dup + strlen("name=");
if (start != NULL) {
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 03/16] bus/fslmc: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
2023-11-10 6:36 ` [PATCH 01/16] eal: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 02/16] bus/dpaa: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 04/16] bus/vdev: " Chengwen Feng
` (12 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Hemant Agrawal, Sachin Saxena, Shreyansh Jain; +Cc: dev
Add verify strdup return value logic.
Fixes: e67a61614d0b ("bus/fslmc: support device iteration")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/bus/fslmc/fslmc_bus.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 57bfb5111a..89f0f329c0 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -634,6 +634,10 @@ fslmc_bus_dev_iterate(const void *start, const char *str,
/* Now that name=device_name format is available, split */
dup = strdup(str);
+ if (dup == NULL) {
+ DPAA2_BUS_DEBUG("Dup string (%s) failed!\n", str);
+ return NULL;
+ }
dev_name = dup + strlen("name=");
if (start != NULL) {
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 04/16] bus/vdev: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (2 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 03/16] bus/fslmc: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 05/16] dma/idxd: " Chengwen Feng
` (11 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gaetan Rivet, Ray Kinsella, Xueming Li; +Cc: dev
Add verify strdup return value logic.
Fixes: 64051bb1f144 ("devargs: unify scratch buffer storage")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/bus/vdev/vdev.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 7974b27295..05582f1727 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -247,6 +247,10 @@ alloc_devargs(const char *name, const char *args)
devargs->data = strdup(args);
else
devargs->data = strdup("");
+ if (devargs->data == NULL) {
+ free(devargs);
+ return NULL;
+ }
devargs->args = devargs->data;
ret = strlcpy(devargs->name, name, sizeof(devargs->name));
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 05/16] dma/idxd: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (3 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 04/16] bus/vdev: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 06/16] event/cnxk: " Chengwen Feng
` (10 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Bruce Richardson, Kevin Laatz, Conor Walsh; +Cc: dev
Add verify strdup return value logic.
Fixes: e888bb1278c6 ("dma/idxd: add bus device probing")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/dma/idxd/idxd_bus.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c
index 3b2d4c2b65..ba8076715d 100644
--- a/drivers/dma/idxd/idxd_bus.c
+++ b/drivers/dma/idxd/idxd_bus.c
@@ -261,9 +261,15 @@ static int
is_for_this_process_use(struct rte_dsa_device *dev, const char *name)
{
char *runtime_dir = strdup(rte_eal_get_runtime_dir());
- char *prefix = basename(runtime_dir);
- int prefixlen = strlen(prefix);
int retval = 0;
+ int prefixlen;
+ char *prefix;
+
+ if (runtime_dir == NULL)
+ return retval;
+
+ prefix = basename(runtime_dir);
+ prefixlen = strlen(prefix);
if (strncmp(name, "dpdk_", 5) == 0)
retval = 1;
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 06/16] event/cnxk: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (4 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 05/16] dma/idxd: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 07/16] net/failsafe: fix memory leak when parse args Chengwen Feng
` (9 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Pavan Nikhilesh, Shijith Thotton; +Cc: dev
Add verify strdup return value logic.
Fixes: 38c2e3240ba8 ("event/cnxk: add option to control SSO HWGRP QoS")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/event/cnxk/cnxk_eventdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/event/cnxk/cnxk_eventdev.c b/drivers/event/cnxk/cnxk_eventdev.c
index 0c61f4c20e..1ec281e735 100644
--- a/drivers/event/cnxk/cnxk_eventdev.c
+++ b/drivers/event/cnxk/cnxk_eventdev.c
@@ -553,6 +553,9 @@ parse_list(const char *value, void *opaque, param_parse_t fn)
char *end = NULL;
char *f = s;
+ if (s == NULL)
+ return;
+
while (*s) {
if (*s == '[')
start = s;
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 07/16] net/failsafe: fix memory leak when parse args
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (5 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 06/16] event/cnxk: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 08/16] net/nfp: verify strdup return value Chengwen Feng
` (8 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Gaetan Rivet, Olga Shern; +Cc: dev
Should free the memory which allocated by strdup().
Fixes: a46f8d584eb8 ("net/failsafe: add fail-safe PMD")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/failsafe/failsafe_args.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c
index b203e02d9a..3b867437d7 100644
--- a/drivers/net/failsafe/failsafe_args.c
+++ b/drivers/net/failsafe/failsafe_args.c
@@ -248,7 +248,7 @@ fs_parse_device_param(struct rte_eth_dev *dev, const char *param,
goto free_args;
} else {
ERROR("Unrecognized device type: %.*s", (int)b, param);
- return -EINVAL;
+ ret = -EINVAL;
}
free_args:
free(args);
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 08/16] net/nfp: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (6 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 07/16] net/failsafe: fix memory leak when parse args Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:58 ` Chaoyong He
2023-11-10 6:36 ` [PATCH 09/16] app/dumpcap: " Chengwen Feng
` (7 subsequent siblings)
15 siblings, 1 reply; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Chaoyong He, Chang Miao, Shihong Wang; +Cc: dev
Add verify strdup return value logic.
Fixes: 3d21da66c06b ("net/nfp: create security session")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
drivers/net/nfp/nfp_ipsec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index 452947380e..7ce9cca0b2 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -524,6 +524,11 @@ nfp_aesgcm_iv_update(struct ipsec_add_sa *cfg,
uint8_t *cfg_iv;
iv_str = strdup(iv_string);
+ if (iv_str == NULL) {
+ PMD_DRV_LOG(ERR, "Failed to strdup iv_string");
+ return;
+ }
+
cfg_iv = (uint8_t *)cfg->aesgcm_fields.iv;
for (i = 0; i < iv_len; i++) {
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 09/16] app/dumpcap: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (7 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 08/16] net/nfp: verify strdup return value Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 10/16] app/pdump: " Chengwen Feng
` (6 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Reshma Pattan, Stephen Hemminger; +Cc: dev
Add verify strdup return value logic.
Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/dumpcap/main.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 64294bbfb3..6ae2446dd9 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -639,6 +639,11 @@ static void dpdk_init(void)
eal_argv[i++] = strdup(file_prefix);
}
+ for (i = 0; i < eal_argc; i++) {
+ if (eal_argv[i] == NULL)
+ rte_panic("No memory\n");
+ }
+
if (rte_eal_init(eal_argc, eal_argv) < 0)
rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n");
}
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 10/16] app/pdump: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (8 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 09/16] app/dumpcap: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 11/16] app/test: " Chengwen Feng
` (5 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Reshma Pattan, Stephen Hemminger,
konstantin.ananyev
Cc: dev
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(+)
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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 11/16] app/test: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (9 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 10/16] app/pdump: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 12/16] app/test-crypto-perf: " Chengwen Feng
` (4 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit; +Cc: dev
Add verify strdup return value logic.
Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/test/process.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/test/process.h b/app/test/process.h
index af7bc3e0de..c576c42349 100644
--- a/app/test/process.h
+++ b/app/test/process.h
@@ -59,8 +59,11 @@ process_dup(const char *const argv[], int numargs, const char *env_value)
return -1;
else if (pid == 0) {
/* make a copy of the arguments to be passed to exec */
- for (i = 0; i < numargs; i++)
+ for (i = 0; i < numargs; i++) {
argv_cpy[i] = strdup(argv[i]);
+ if (argv_cpy[i] == NULL)
+ rte_panic("Error dup args\n");
+ }
argv_cpy[i] = NULL;
num = numargs;
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 12/16] app/test-crypto-perf: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (10 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 11/16] app/test: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 13/16] app/test-dma-perf: " Chengwen Feng
` (3 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Ciara Power, Piotr Azarewicz,
Marcin Kerlin, Michal Kobylinski, Declan Doherty,
Slawomir Mrozowicz
Cc: dev
Add verify strdup return value logic.
Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/test-crypto-perf/cperf_options_parsing.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/test-crypto-perf/cperf_options_parsing.c b/app/test-crypto-perf/cperf_options_parsing.c
index 75afedc7fd..8909b5690d 100644
--- a/app/test-crypto-perf/cperf_options_parsing.c
+++ b/app/test-crypto-perf/cperf_options_parsing.c
@@ -516,6 +516,10 @@ parse_test_file(struct cperf_options *opts,
const char *arg)
{
opts->test_file = strdup(arg);
+ if (opts->test_file == NULL) {
+ RTE_LOG(ERR, USER1, "Dup vector file failed!\n");
+ return -1;
+ }
if (access(opts->test_file, F_OK) != -1)
return 0;
RTE_LOG(ERR, USER1, "Test vector file doesn't exist\n");
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 13/16] app/test-dma-perf: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (11 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 12/16] app/test-crypto-perf: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 14/16] app/testpmd: " Chengwen Feng
` (2 subsequent siblings)
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Cheng Jiang, Morten Brørup,
Anoob Joseph, Yuan Wang, Jiayu Hu
Cc: dev
Add verify strdup return value logic.
Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/test-dma-perf/main.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
index e5bccc27da..339ee25eb5 100644
--- a/app/test-dma-perf/main.c
+++ b/app/test-dma-perf/main.c
@@ -206,6 +206,8 @@ parse_lcore_dma(struct test_configure *test_case, const char *value)
return -1;
input = strndup(value, strlen(value) + 1);
+ if (input == NULL)
+ return -1;
addrs = input;
while (*addrs == '\0')
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 14/16] app/testpmd: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (12 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 13/16] app/test-dma-perf: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 15/16] examples/qos_sched: fix memory leak when parse args Chengwen Feng
2023-11-10 6:36 ` [PATCH 16/16] examples/vhost: verify strdup return value Chengwen Feng
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Aman Singh, Yuying Zhang, Xuan Ding,
Andrew Rybchenko, Wenxuan Wu, Yuan Wang
Cc: dev
Add verify strdup return value logic.
Fixes: 52e2e7edcf48 ("app/testpmd: add protocol-based buffer split")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/test-pmd/cmdline.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 912bf3355c..904c04d466 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3528,6 +3528,8 @@ parse_hdrs_list(const char *str, const char *item_name, unsigned int max_items,
nb_item = 0;
char *str2 = strdup(str);
+ if (str2 == NULL)
+ return nb_item;
cur = strtok_r(str2, ",", &tmp);
while (cur != NULL) {
parsed_items[nb_item] = get_ptype(cur);
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 15/16] examples/qos_sched: fix memory leak when parse args
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (13 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 14/16] app/testpmd: " Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
2023-11-10 6:36 ` [PATCH 16/16] examples/vhost: verify strdup return value Chengwen Feng
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Cristian Dumitrescu, Slawomir Mrozowicz; +Cc: dev
Should free the memory which allocated by strdup().
Fixes: 035b6a4f4bba ("examples/qos_sched: fix out-of-bounds option parsing")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
examples/qos_sched/args.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/examples/qos_sched/args.c b/examples/qos_sched/args.c
index e97273152a..8d61d3e454 100644
--- a/examples/qos_sched/args.c
+++ b/examples/qos_sched/args.c
@@ -103,8 +103,10 @@ app_parse_opt_vals(const char *conf_str, char separator, uint32_t n_vals, uint32
n_tokens = rte_strsplit(string, strnlen(string, 32), tokens, n_vals, separator);
- if (n_tokens > MAX_OPT_VALUES)
+ if (n_tokens > MAX_OPT_VALUES) {
+ free(string);
return -1;
+ }
for (i = 0; i < n_tokens; i++)
opt_vals[i] = (uint32_t)atol(tokens[i]);
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 16/16] examples/vhost: verify strdup return value
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
` (14 preceding siblings ...)
2023-11-10 6:36 ` [PATCH 15/16] examples/qos_sched: fix memory leak when parse args Chengwen Feng
@ 2023-11-10 6:36 ` Chengwen Feng
15 siblings, 0 replies; 18+ messages in thread
From: Chengwen Feng @ 2023-11-10 6:36 UTC (permalink / raw)
To: thomas, ferruh.yigit, Maxime Coquelin, Chenbo Xia, Sunil Pai G, Jiayu Hu
Cc: dev
Add verify strdup return value logic.
Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
examples/vhost/main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index ce5c1efddf..3fc1b151d1 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -260,6 +260,9 @@ open_dma(const char *value)
char *dma_arg[RTE_MAX_VHOST_DEVICE];
int args_nr;
+ if (input == NULL)
+ return -1;
+
while (isblank(*addrs))
addrs++;
if (*addrs == '\0') {
--
2.17.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* RE: [PATCH 08/16] net/nfp: verify strdup return value
2023-11-10 6:36 ` [PATCH 08/16] net/nfp: verify strdup return value Chengwen Feng
@ 2023-11-10 6:58 ` Chaoyong He
0 siblings, 0 replies; 18+ messages in thread
From: Chaoyong He @ 2023-11-10 6:58 UTC (permalink / raw)
To: Chengwen Feng, thomas, ferruh.yigit, Chang Miao, Shihong Wang; +Cc: dev
> [You don't often get email from fengchengwen@huawei.com. Learn why this
> is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Add verify strdup return value logic.
>
> Fixes: 3d21da66c06b ("net/nfp: create security session")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> drivers/net/nfp/nfp_ipsec.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c index
> 452947380e..7ce9cca0b2 100644
> --- a/drivers/net/nfp/nfp_ipsec.c
> +++ b/drivers/net/nfp/nfp_ipsec.c
> @@ -524,6 +524,11 @@ nfp_aesgcm_iv_update(struct ipsec_add_sa *cfg,
> uint8_t *cfg_iv;
>
> iv_str = strdup(iv_string);
> + if (iv_str == NULL) {
> + PMD_DRV_LOG(ERR, "Failed to strdup iv_string");
> + return;
> + }
> +
> cfg_iv = (uint8_t *)cfg->aesgcm_fields.iv;
>
> for (i = 0; i < iv_len; i++) {
> --
> 2.17.1
Looks good tome.
Thanks.
Acked-by: Chaoyong He <chaoyong.he@corigine.com>
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2023-11-10 6:58 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 6:36 [PATCH 00/16] verify strdup return value Chengwen Feng
2023-11-10 6:36 ` [PATCH 01/16] eal: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 02/16] bus/dpaa: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 03/16] bus/fslmc: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 04/16] bus/vdev: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 05/16] dma/idxd: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 06/16] event/cnxk: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 07/16] net/failsafe: fix memory leak when parse args Chengwen Feng
2023-11-10 6:36 ` [PATCH 08/16] net/nfp: verify strdup return value Chengwen Feng
2023-11-10 6:58 ` Chaoyong He
2023-11-10 6:36 ` [PATCH 09/16] app/dumpcap: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 10/16] app/pdump: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 11/16] app/test: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 12/16] app/test-crypto-perf: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 13/16] app/test-dma-perf: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 14/16] app/testpmd: " Chengwen Feng
2023-11-10 6:36 ` [PATCH 15/16] examples/qos_sched: fix memory leak when parse args Chengwen Feng
2023-11-10 6:36 ` [PATCH 16/16] examples/vhost: verify strdup return value Chengwen Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).