DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] putting null checks on ops_name
@ 2020-04-06 11:30 Muhammad Bilal
  2020-04-06 15:20 ` Stephen Hemminger
  2020-04-07  7:56 ` [dpdk-dev] [PATCH v2] " Muhammad Bilal
  0 siblings, 2 replies; 5+ messages in thread
From: Muhammad Bilal @ 2020-04-06 11:30 UTC (permalink / raw)
  To: hemant.agrawal, olivier.matz; +Cc: dev, Muhammad Bilal, stable

Bugzilla ID: 353
Cc: dev@dpdk.org
Cc: stable@dpdk.org
Cc: hemant.agrawal@nxp.com
Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
---
 lib/librte_mbuf/rte_mbuf_pool_ops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c
index 5722976fe..c3ddfc0bd 100644
--- a/lib/librte_mbuf/rte_mbuf_pool_ops.c
+++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c
@@ -13,7 +13,8 @@ int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
 	const struct rte_memzone *mz;
-
+	if (strlen(ops_name) == 0)
+		return -1;
 	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
 		return -ENAMETOOLONG;
 
@@ -50,7 +51,8 @@ int
 rte_mbuf_set_user_mempool_ops(const char *ops_name)
 {
 	const struct rte_memzone *mz;
-
+	if (strlen(ops_name) == 0)
+		return -1;
 	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
 		return -ENAMETOOLONG;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH] putting null checks on ops_name
  2020-04-06 11:30 [dpdk-dev] [PATCH] putting null checks on ops_name Muhammad Bilal
@ 2020-04-06 15:20 ` Stephen Hemminger
  2020-04-07  7:56 ` [dpdk-dev] [PATCH v2] " Muhammad Bilal
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2020-04-06 15:20 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: hemant.agrawal, olivier.matz, dev, stable

On Mon,  6 Apr 2020 16:30:20 +0500
Muhammad Bilal <m.bilal@emumba.com> wrote:

> Bugzilla ID: 353
> Cc: dev@dpdk.org
> Cc: stable@dpdk.org
> Cc: hemant.agrawal@nxp.com
> Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
> ---
>  lib/librte_mbuf/rte_mbuf_pool_ops.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c
> index 5722976fe..c3ddfc0bd 100644
> --- a/lib/librte_mbuf/rte_mbuf_pool_ops.c
> +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c
> @@ -13,7 +13,8 @@ int
>  rte_mbuf_set_platform_mempool_ops(const char *ops_name)
>  {
>  	const struct rte_memzone *mz;
> -
> +	if (strlen(ops_name) == 0)
> +		return -1;
>  	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
>  		return -ENAMETOOLONG;
>  
> @@ -50,7 +51,8 @@ int
>  rte_mbuf_set_user_mempool_ops(const char *ops_name)
>  {
>  	const struct rte_memzone *mz;
> -
> +	if (strlen(ops_name) == 0)
> +		return -1;
>  	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
>  		return -ENAMETOOLONG;
>  

If you want to do it simpler and safer use strnlen.
Also, don't mix -1 wit -errno returns.

	size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE);

	if (len == 0)
		return -EINVAL;

	if (len == RTE_MEMPOOL_OPS_NAMESIZE)
		return -ENAMETOOLONG;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [dpdk-dev] [PATCH v2] putting null checks on ops_name
  2020-04-06 11:30 [dpdk-dev] [PATCH] putting null checks on ops_name Muhammad Bilal
  2020-04-06 15:20 ` Stephen Hemminger
@ 2020-04-07  7:56 ` Muhammad Bilal
  2020-04-07 10:16   ` Hemant Agrawal
  2020-04-25 20:59   ` Thomas Monjalon
  1 sibling, 2 replies; 5+ messages in thread
From: Muhammad Bilal @ 2020-04-07  7:56 UTC (permalink / raw)
  To: hemant.agrawal, olivier.matz, stephen; +Cc: dev, Muhammad Bilal, stable

Bugzilla ID: 353
Cc: dev@dpdk.org
Cc: stable@dpdk.org
Cc: hemant.agrawal@nxp.com
Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
---
 lib/librte_mbuf/rte_mbuf_pool_ops.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c
index 5722976fe..00186aa15 100644
--- a/lib/librte_mbuf/rte_mbuf_pool_ops.c
+++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c
@@ -13,8 +13,10 @@ int
 rte_mbuf_set_platform_mempool_ops(const char *ops_name)
 {
 	const struct rte_memzone *mz;
-
-	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
+	size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE);
+	if (len == 0)
+		return -EINVAL;
+	if (len == RTE_MEMPOOL_OPS_NAMESIZE)
 		return -ENAMETOOLONG;
 
 	mz = rte_memzone_lookup("mbuf_platform_pool_ops");
@@ -50,8 +52,10 @@ int
 rte_mbuf_set_user_mempool_ops(const char *ops_name)
 {
 	const struct rte_memzone *mz;
-
-	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
+	size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE);
+	if (len == 0)
+		return -EINVAL;
+	if (len == RTE_MEMPOOL_OPS_NAMESIZE)
 		return -ENAMETOOLONG;
 
 	mz = rte_memzone_lookup("mbuf_user_pool_ops");
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] putting null checks on ops_name
  2020-04-07  7:56 ` [dpdk-dev] [PATCH v2] " Muhammad Bilal
@ 2020-04-07 10:16   ` Hemant Agrawal
  2020-04-25 20:59   ` Thomas Monjalon
  1 sibling, 0 replies; 5+ messages in thread
From: Hemant Agrawal @ 2020-04-07 10:16 UTC (permalink / raw)
  To: Muhammad Bilal, olivier.matz, stephen; +Cc: dev, stable

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v2] putting null checks on ops_name
  2020-04-07  7:56 ` [dpdk-dev] [PATCH v2] " Muhammad Bilal
  2020-04-07 10:16   ` Hemant Agrawal
@ 2020-04-25 20:59   ` Thomas Monjalon
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2020-04-25 20:59 UTC (permalink / raw)
  To: Muhammad Bilal; +Cc: hemant.agrawal, olivier.matz, stephen, dev, stable

07/04/2020 09:56, Muhammad Bilal:
> Bugzilla ID: 353
> Cc: dev@dpdk.org
> Cc: stable@dpdk.org
> Cc: hemant.agrawal@nxp.com
> Signed-off-by: Muhammad Bilal <m.bilal@emumba.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

No need to Cc stable in my opinion, as there is no bug fixed.

Changing the name to:
	mbuf: prevent setting mempool ops name empty

Applied with below minor change, thanks


The blank line below should remain:

>  	const struct rte_memzone *mz;
> -
> -	if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE)
> +	size_t len = strnlen(ops_name, RTE_MEMPOOL_OPS_NAMESIZE);
> +	if (len == 0)
> +		return -EINVAL;




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-25 21:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 11:30 [dpdk-dev] [PATCH] putting null checks on ops_name Muhammad Bilal
2020-04-06 15:20 ` Stephen Hemminger
2020-04-07  7:56 ` [dpdk-dev] [PATCH v2] " Muhammad Bilal
2020-04-07 10:16   ` Hemant Agrawal
2020-04-25 20:59   ` Thomas Monjalon

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).