[v4,04/15] crypto: fix raw process for multi-seg case

Message ID 20211013190032.2308-5-hemant.agrawal@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series crypto: add raw vector support in DPAAx |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Hemant Agrawal Oct. 13, 2021, 7 p.m. UTC
  From: Gagandeep Singh <g.singh@nxp.com>

If no next segment available the “for” loop will fail and it still
returns i+1 i.e. 2, which is wrong as it has filled only 1 buffer.

Fixes: 7adf992fb9bf ("cryptodev: introduce CPU crypto API")
Cc: marcinx.smoczynski@intel.com
Cc: stable@dpdk.org

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 lib/cryptodev/rte_crypto_sym.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Ananyev, Konstantin Oct. 15, 2021, 5:39 p.m. UTC | #1
> 
> From: Gagandeep Singh <g.singh@nxp.com>
> 
> If no next segment available the “for” loop will fail and it still
> returns i+1 i.e. 2, which is wrong as it has filled only 1 buffer.
> 
> Fixes: 7adf992fb9bf ("cryptodev: introduce CPU crypto API")
> Cc: marcinx.smoczynski@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
> ---
>  lib/cryptodev/rte_crypto_sym.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
> index b6a229e263..dc88ad6dcc 100644
> --- a/lib/cryptodev/rte_crypto_sym.h
> +++ b/lib/cryptodev/rte_crypto_sym.h
> @@ -1004,6 +1004,7 @@ rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
>  			vec[i].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb)
>  					- ofs;
>  			left = 0;
> +			i++;
>  			break;
>  		}
> 
> @@ -1014,7 +1015,7 @@ rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
>  	}
> 
>  	RTE_ASSERT(left == 0);
> -	return i + 1;
> +	return i;
>  }
> 
> 
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 2.17.1
  

Patch

diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
index b6a229e263..dc88ad6dcc 100644
--- a/lib/cryptodev/rte_crypto_sym.h
+++ b/lib/cryptodev/rte_crypto_sym.h
@@ -1004,6 +1004,7 @@  rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
 			vec[i].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb)
 					- ofs;
 			left = 0;
+			i++;
 			break;
 		}
 
@@ -1014,7 +1015,7 @@  rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
 	}
 
 	RTE_ASSERT(left == 0);
-	return i + 1;
+	return i;
 }