DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5/hws: fix possible negative return on sq create
@ 2022-11-03 12:51 Alex Vesker
  2022-11-03 14:16 ` Alex Vesker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alex Vesker @ 2022-11-03 12:51 UTC (permalink / raw)
  To: valex, viacheslavo, thomas, suanmingm, Matan Azrad; +Cc: dev, orika

The sysconf call can return a negative value (-1) on failure
this will lead to posix_memalign to fail. This is not a realistic
case which was found by the static checkers.

Fixes: 3eb7488 ("net/mlx5/hws: add send layer")
Signed-off-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_send.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c b/drivers/net/mlx5/hws/mlx5dr_send.c
index 26904a9040..1e9953a38f 100644
--- a/drivers/net/mlx5/hws/mlx5dr_send.c
+++ b/drivers/net/mlx5/hws/mlx5dr_send.c
@@ -524,6 +524,7 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	size_t sq_log_buf_sz;
 	size_t buf_aligned;
 	size_t sq_buf_sz;
+	size_t page_size;
 	size_t buf_sz;
 	int err;
 
@@ -532,8 +533,9 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB));
 	sq->reg_addr = queue->uar->reg_addr;
 
-	buf_aligned = align(sq_buf_sz, sysconf(_SC_PAGESIZE));
-	err = posix_memalign((void **)&sq->buf, sysconf(_SC_PAGESIZE), buf_aligned);
+	page_size = sysconf(_SC_PAGESIZE);
+	buf_aligned = align(sq_buf_sz, page_size);
+	err = posix_memalign((void **)&sq->buf, page_size, buf_aligned);
 	if (err) {
 		rte_errno = ENOMEM;
 		return err;
-- 
2.18.1


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

* RE: [PATCH] net/mlx5/hws: fix possible negative return on sq create
  2022-11-03 12:51 [PATCH] net/mlx5/hws: fix possible negative return on sq create Alex Vesker
@ 2022-11-03 14:16 ` Alex Vesker
  2022-11-07  9:54 ` [PATCH 4/4] " Alex Vesker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Vesker @ 2022-11-03 14:16 UTC (permalink / raw)
  To: Slava Ovsiienko, NBU-Contact-Thomas Monjalon (EXTERNAL),
	Suanming Mou, Matan Azrad
  Cc: dev, Ori Kam

Also forgot to add to commit message:
Coverity issue: 381674

> -----Original Message-----
> From: Alex Vesker <valex@nvidia.com>
> Sent: Thursday, November 3, 2022 2:52 PM
> To: Alex Vesker <valex@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; NBU-Contact-Thomas Monjalon (EXTERNAL)
> <thomas@monjalon.net>; Suanming Mou <suanmingm@nvidia.com>;
> Matan Azrad <matan@nvidia.com>
> Cc: dev@dpdk.org; Ori Kam <orika@nvidia.com>
> Subject: [PATCH] net/mlx5/hws: fix possible negative return on sq create
> 
> The sysconf call can return a negative value (-1) on failure this will lead to
> posix_memalign to fail. This is not a realistic case which was found by the
> static checkers.
> 
> Fixes: 3eb7488 ("net/mlx5/hws: add send layer")
> Signed-off-by: Alex Vesker <valex@nvidia.com>
> Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
> ---
>  drivers/net/mlx5/hws/mlx5dr_send.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c
> b/drivers/net/mlx5/hws/mlx5dr_send.c
> index 26904a9040..1e9953a38f 100644
> --- a/drivers/net/mlx5/hws/mlx5dr_send.c
> +++ b/drivers/net/mlx5/hws/mlx5dr_send.c
> @@ -524,6 +524,7 @@ static int mlx5dr_send_ring_open_sq(struct
> mlx5dr_context *ctx,
>  	size_t sq_log_buf_sz;
>  	size_t buf_aligned;
>  	size_t sq_buf_sz;
> +	size_t page_size;
>  	size_t buf_sz;
>  	int err;
> 
> @@ -532,8 +533,9 @@ static int mlx5dr_send_ring_open_sq(struct
> mlx5dr_context *ctx,
>  	sq_buf_sz = 1 << (sq_log_buf_sz +
> log2above(MLX5_SEND_WQE_BB));
>  	sq->reg_addr = queue->uar->reg_addr;
> 
> -	buf_aligned = align(sq_buf_sz, sysconf(_SC_PAGESIZE));
> -	err = posix_memalign((void **)&sq->buf, sysconf(_SC_PAGESIZE),
> buf_aligned);
> +	page_size = sysconf(_SC_PAGESIZE);
> +	buf_aligned = align(sq_buf_sz, page_size);
> +	err = posix_memalign((void **)&sq->buf, page_size, buf_aligned);
>  	if (err) {
>  		rte_errno = ENOMEM;
>  		return err;
> --
> 2.18.1


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

* [PATCH 4/4] net/mlx5/hws: fix possible negative return on sq create
  2022-11-03 12:51 [PATCH] net/mlx5/hws: fix possible negative return on sq create Alex Vesker
  2022-11-03 14:16 ` Alex Vesker
@ 2022-11-07  9:54 ` Alex Vesker
  2022-11-07 10:08 ` [PATCH] " Alex Vesker
  2022-11-08  8:58 ` Raslan Darawsheh
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Vesker @ 2022-11-07  9:54 UTC (permalink / raw)
  To: valex, viacheslavo, thomas, suanmingm, Matan Azrad; +Cc: dev, orika

The sysconf call can return a negative value (-1) on failure
this will lead to posix_memalign to fail. This is not a realistic
case which was found by the static checkers.

Coverity issue: 381674
Fixes: 3eb7488 ("net/mlx5/hws: add send layer")
Signed-off-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_send.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c b/drivers/net/mlx5/hws/mlx5dr_send.c
index 26904a9040..1e9953a38f 100644
--- a/drivers/net/mlx5/hws/mlx5dr_send.c
+++ b/drivers/net/mlx5/hws/mlx5dr_send.c
@@ -524,6 +524,7 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	size_t sq_log_buf_sz;
 	size_t buf_aligned;
 	size_t sq_buf_sz;
+	size_t page_size;
 	size_t buf_sz;
 	int err;
 
@@ -532,8 +533,9 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB));
 	sq->reg_addr = queue->uar->reg_addr;
 
-	buf_aligned = align(sq_buf_sz, sysconf(_SC_PAGESIZE));
-	err = posix_memalign((void **)&sq->buf, sysconf(_SC_PAGESIZE), buf_aligned);
+	page_size = sysconf(_SC_PAGESIZE);
+	buf_aligned = align(sq_buf_sz, page_size);
+	err = posix_memalign((void **)&sq->buf, page_size, buf_aligned);
 	if (err) {
 		rte_errno = ENOMEM;
 		return err;
-- 
2.18.1


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

* [PATCH] net/mlx5/hws: fix possible negative return on sq create
  2022-11-03 12:51 [PATCH] net/mlx5/hws: fix possible negative return on sq create Alex Vesker
  2022-11-03 14:16 ` Alex Vesker
  2022-11-07  9:54 ` [PATCH 4/4] " Alex Vesker
@ 2022-11-07 10:08 ` Alex Vesker
  2022-11-08  8:58 ` Raslan Darawsheh
  3 siblings, 0 replies; 5+ messages in thread
From: Alex Vesker @ 2022-11-07 10:08 UTC (permalink / raw)
  To: valex, viacheslavo, thomas, suanmingm, Matan Azrad; +Cc: dev, orika

The sysconf call can return a negative value (-1) on failure
this will lead to posix_memalign to fail. This is not a realistic
case which was found by the static checkers.

Coverity issue: 381674
Fixes: 3eb7488 ("net/mlx5/hws: add send layer")
Signed-off-by: Alex Vesker <valex@nvidia.com>
Reviewed-by: Erez Shitrit <erezsh@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_send.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_send.c b/drivers/net/mlx5/hws/mlx5dr_send.c
index 26904a9040..1e9953a38f 100644
--- a/drivers/net/mlx5/hws/mlx5dr_send.c
+++ b/drivers/net/mlx5/hws/mlx5dr_send.c
@@ -524,6 +524,7 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	size_t sq_log_buf_sz;
 	size_t buf_aligned;
 	size_t sq_buf_sz;
+	size_t page_size;
 	size_t buf_sz;
 	int err;
 
@@ -532,8 +533,9 @@ static int mlx5dr_send_ring_open_sq(struct mlx5dr_context *ctx,
 	sq_buf_sz = 1 << (sq_log_buf_sz + log2above(MLX5_SEND_WQE_BB));
 	sq->reg_addr = queue->uar->reg_addr;
 
-	buf_aligned = align(sq_buf_sz, sysconf(_SC_PAGESIZE));
-	err = posix_memalign((void **)&sq->buf, sysconf(_SC_PAGESIZE), buf_aligned);
+	page_size = sysconf(_SC_PAGESIZE);
+	buf_aligned = align(sq_buf_sz, page_size);
+	err = posix_memalign((void **)&sq->buf, page_size, buf_aligned);
 	if (err) {
 		rte_errno = ENOMEM;
 		return err;
-- 
2.18.1


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

* RE: [PATCH] net/mlx5/hws: fix possible negative return on sq create
  2022-11-03 12:51 [PATCH] net/mlx5/hws: fix possible negative return on sq create Alex Vesker
                   ` (2 preceding siblings ...)
  2022-11-07 10:08 ` [PATCH] " Alex Vesker
@ 2022-11-08  8:58 ` Raslan Darawsheh
  3 siblings, 0 replies; 5+ messages in thread
From: Raslan Darawsheh @ 2022-11-08  8:58 UTC (permalink / raw)
  To: Alex Vesker, Alex Vesker, Slava Ovsiienko,
	NBU-Contact-Thomas Monjalon (EXTERNAL),
	Suanming Mou, Matan Azrad
  Cc: dev, Ori Kam

Hi,

> -----Original Message-----
> From: Alex Vesker <valex@nvidia.com>
> Sent: Thursday, November 3, 2022 2:52 PM
> To: Alex Vesker <valex@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; NBU-Contact-Thomas Monjalon (EXTERNAL)
> <thomas@monjalon.net>; Suanming Mou <suanmingm@nvidia.com>;
> Matan Azrad <matan@nvidia.com>
> Cc: dev@dpdk.org; Ori Kam <orika@nvidia.com>
> Subject: [PATCH] net/mlx5/hws: fix possible negative return on sq create
> 
> The sysconf call can return a negative value (-1) on failure
> this will lead to posix_memalign to fail. This is not a realistic
> case which was found by the static checkers.
> 
> Fixes: 3eb7488 ("net/mlx5/hws: add send layer")
missing empty line between fixes and signed-off-by will handle during integration.

> Signed-off-by: Alex Vesker <valex@nvidia.com>
> Reviewed-by: Erez Shitrit <erezsh@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

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

end of thread, other threads:[~2022-11-08  8:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 12:51 [PATCH] net/mlx5/hws: fix possible negative return on sq create Alex Vesker
2022-11-03 14:16 ` Alex Vesker
2022-11-07  9:54 ` [PATCH 4/4] " Alex Vesker
2022-11-07 10:08 ` [PATCH] " Alex Vesker
2022-11-08  8:58 ` Raslan Darawsheh

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