From: Jun Yang <jun.y...@nxp.com>

Make sure the SG entry number doesn't overflow.

Signed-off-by: Jun Yang <jun.y...@nxp.com>
---
 drivers/dma/dpaa2/dpaa2_qdma.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c
index 44b82c139e..7f6ebcb46b 100644
--- a/drivers/dma/dpaa2/dpaa2_qdma.c
+++ b/drivers/dma/dpaa2/dpaa2_qdma.c
@@ -615,8 +615,17 @@ dpaa2_qdma_copy_sg(void *dev_private,
        struct qbman_fle *fle;
        struct qdma_sdd *sdd;
 
-       if (unlikely(nb_src != nb_dst))
+       if (unlikely(nb_src != nb_dst)) {
+               DPAA2_QDMA_ERR("SG entry src num(%d) != dst num(%d)",
+                       nb_src, nb_dst);
                return -ENOTSUP;
+       }
+
+       if (unlikely(nb_src > RTE_DPAA2_QDMA_JOB_SUBMIT_MAX)) {
+               DPAA2_QDMA_ERR("SG entry number(%d) > MAX(%d)",
+                       nb_src, RTE_DPAA2_QDMA_JOB_SUBMIT_MAX);
+               return -EINVAL;
+       }
 
        memset(fd, 0, sizeof(struct qbman_fd));
 
-- 
2.25.1

Reply via email to