DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shijith Thotton <sthotton@marvell.com>
To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
	"Vidya Sagar Velumuri" <vvelumuri@marvell.com>
Cc: <dev@dpdk.org>, Shijith Thotton <sthotton@marvell.com>
Subject: [PATCH v1 2/2] dma/odm: avoid zero length DMA transfers
Date: Mon, 1 Jun 2026 15:45:59 +0530	[thread overview]
Message-ID: <20260601101559.1925302-3-sthotton@marvell.com> (raw)
In-Reply-To: <20260601101559.1925302-1-sthotton@marvell.com>

Add validation to reject zero-length DMA operations early
with -EINVAL, preventing queue disable.

Signed-off-by: Shijith Thotton <sthotton@marvell.com>
---
 drivers/dma/odm/odm_dmadev.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/odm/odm_dmadev.c b/drivers/dma/odm/odm_dmadev.c
index 0211133bd4..7488b960fd 100644
--- a/drivers/dma/odm/odm_dmadev.c
+++ b/drivers/dma/odm/odm_dmadev.c
@@ -110,6 +110,9 @@ odm_dmadev_copy(void *dev_private, uint16_t vchan, rte_iova_t src, rte_iova_t ds
 	vq = &odm->vq[vchan];
 	hdr.s.xtype = vq->xtype;
 
+	if (unlikely(!length))
+		return -EINVAL;
+
 	h = length;
 	h |= ((uint64_t)length << 32);
 
@@ -262,14 +265,20 @@ odm_dmadev_copy_sg(void *dev_private, uint16_t vchan, const struct rte_dma_sge *
 	pending_submit_len = vq->pending_submit_len;
 	pending_submit_cnt = vq->pending_submit_cnt;
 
-	if (unlikely(nb_src > 4 || nb_dst > 4))
+	if (unlikely(!nb_src || nb_src > 4 || !nb_dst || nb_dst > 4))
 		return -EINVAL;
 
-	for (i = 0; i < nb_src; i++)
+	for (i = 0; i < nb_src; i++) {
+		if (unlikely(!src[i].length))
+			return -EINVAL;
 		s_sz += src[i].length;
+	}
 
-	for (i = 0; i < nb_dst; i++)
+	for (i = 0; i < nb_dst; i++) {
+		if (unlikely(!dst[i].length))
+			return -EINVAL;
 		d_sz += dst[i].length;
+	}
 
 	if (s_sz != d_sz)
 		return -EINVAL;
@@ -342,6 +351,9 @@ odm_dmadev_fill(void *dev_private, uint16_t vchan, uint64_t pattern, rte_iova_t
 		.s.nlst = 1,
 	};
 
+	if (unlikely(!length))
+		return -EINVAL;
+
 	h = (uint64_t)length;
 
 	switch (pattern) {
-- 
2.25.1


  parent reply	other threads:[~2026-06-01 10:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 10:15 [PATCH v1 0/2] dma/odm: dev-to-mem support and zero-length validation Shijith Thotton
2026-06-01 10:15 ` [PATCH v1 1/2] dma/odm: support dev to mem transfers Shijith Thotton
2026-06-01 10:15 ` Shijith Thotton [this message]
2026-06-08 16:26   ` [PATCH v1 2/2] dma/odm: avoid zero length DMA transfers Jerin Jacob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260601101559.1925302-3-sthotton@marvell.com \
    --to=sthotton@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gmuthukrishn@marvell.com \
    --cc=vvelumuri@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox