[dpdk-dev] crypto/dpaa_sec: add check for segmented buffer

Message ID 20171012130726.4332-1-alok.makhariya@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

alok.makhariya@nxp.com Oct. 12, 2017, 1:07 p.m. UTC
  From: Alok Makhariya <alok.makhariya@nxp.com>

The code would crash in case of segmented buffer if no check

Fixes: 89aaf708d44b ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform")

Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
---
 drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Akhil Goyal Oct. 13, 2017, 2:43 p.m. UTC | #1
On 10/12/2017 6:37 PM, alok.makhariya@nxp.com wrote:
> From: Alok Makhariya <alok.makhariya@nxp.com>
> 
> The code would crash in case of segmented buffer if no check
> 
> Fixes: 89aaf708d44b ("crypto/dpaa_sec: add crypto driver for NXP DPAA platform")
> 
> Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
> ---
>   drivers/crypto/dpaa_sec/dpaa_sec.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
> index 7b9a683..8a57b96 100644
> --- a/drivers/crypto/dpaa_sec/dpaa_sec.c
> +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
> @@ -893,6 +893,13 @@ dpaa_sec_enqueue_op(struct rte_crypto_op *op,  struct dpaa_sec_qp *qp)
>   			return ret;
>   	}
>   
> +	/*
> +	 * Segmented buffer is not supported.
> +	 */
> +        if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
> +                op->status = RTE_CRYPTO_OP_STATUS_ERROR;
> +                return -ENOTSUP;
> +        }
>   	if (is_auth_only(ses)) {
>   		cf = build_auth_only(op, ses);
>   	} else if (is_cipher_only(ses)) {
> 
It looks there are some checkpatch errors.
  

Patch

diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index 7b9a683..8a57b96 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -893,6 +893,13 @@  dpaa_sec_enqueue_op(struct rte_crypto_op *op,  struct dpaa_sec_qp *qp)
 			return ret;
 	}
 
+	/*
+	 * Segmented buffer is not supported.
+	 */
+        if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
+                op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+                return -ENOTSUP;
+        }
 	if (is_auth_only(ses)) {
 		cf = build_auth_only(op, ses);
 	} else if (is_cipher_only(ses)) {