[05/30] dma/dpaa2: add sanity check for SG entry

Message ID 20240719100126.1150373-5-g.singh@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [01/30] dma/dpaa2: configure route by port by PCIe port param |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gagandeep Singh July 19, 2024, 10:01 a.m. UTC
From: Jun Yang <jun.yang@nxp.com>

Make sure the SG entry number doesn't overflow.

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

Patch

diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c
index 51affed40c..e521df8817 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));