crypto/dpaa2_sec: add check for segmented buffer
authorAlok Makhariya <alok.makhariya@nxp.com>
Fri, 13 Oct 2017 15:38:54 +0000 (21:08 +0530)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 25 Oct 2017 16:10:15 +0000 (18:10 +0200)
The code would crash for segmented buffer if no check.

Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")
Cc: stable@dpdk.org
Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c

index 17365ac..0a466ba 100644 (file)
@@ -548,7 +548,13 @@ build_sec_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
        int ret = -1;
 
        PMD_INIT_FUNC_TRACE();
-
+       /*
+        * Segmented buffer is not supported.
+        */
+       if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
+               op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+               return -ENOTSUP;
+       }
        switch (sess->ctxt_type) {
        case DPAA2_SEC_CIPHER:
                ret = build_cipher_fd(sess, op, fd, bpid);