Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1225101

[PATCH 4/4] dmaengine: at_xdmac: clean used descriptor

From Ludovic Desroches <ludovic.desroches@atmel.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] dmaengine: at_xdmac: clean used descriptor
Date 2015-09-15 15:40 +0200
Message-ID <q8YCJ-6fP-13@gated-at.bofh.it> (permalink)
References <q8Yt4-64o-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


When putting back a descriptor to the free descs list, some fields are
not set to 0, it can cause bugs if someone uses it without having this
in mind.
Descriptor are not put back one by one so it is easier to clean
descriptors when we request them.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: stable@vger.kernel.org #4.2
---
 drivers/dma/at_xdmac.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index fbd4093..b5e132d 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -455,6 +455,15 @@ static struct at_xdmac_desc *at_xdmac_alloc_desc(struct dma_chan *chan,
 	return desc;
 }
 
+void at_xdmac_init_used_desc(struct at_xdmac_desc *desc)
+{
+	memset(&desc->lld, 0, sizeof(desc->lld));
+	INIT_LIST_HEAD(&desc->descs_list);
+	desc->direction = DMA_TRANS_NONE;
+	desc->xfer_size = 0;
+	desc->active_xfer = false;
+}
+
 /* Call must be protected by lock. */
 static struct at_xdmac_desc *at_xdmac_get_desc(struct at_xdmac_chan *atchan)
 {
@@ -466,7 +475,7 @@ static struct at_xdmac_desc *at_xdmac_get_desc(struct at_xdmac_chan *atchan)
 		desc = list_first_entry(&atchan->free_descs_list,
 					struct at_xdmac_desc, desc_node);
 		list_del(&desc->desc_node);
-		desc->active_xfer = false;
+		at_xdmac_init_used_desc(desc);
 	}
 
 	return desc;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] at_xdmac: improvment and fixes for the interleaved mode Ludovic Desroches <ludovic.desroches@atmel.com> - 2015-09-15 15:30 +0200
  [PATCH 1/4] dmaengine: at_xdmac: handle numf > 1 Ludovic Desroches <ludovic.desroches@atmel.com> - 2015-09-15 15:30 +0200
  [PATCH 4/4] dmaengine: at_xdmac: clean used descriptor Ludovic Desroches <ludovic.desroches@atmel.com> - 2015-09-15 15:40 +0200
  [PATCH 2/4] dmaengine: at_xdmac: change block increment addressing mode Ludovic Desroches <ludovic.desroches@atmel.com> - 2015-09-15 15:40 +0200
  [PATCH 3/4] dmaengine: at_xdmac: fix memory leak in interleaved mode Ludovic Desroches <ludovic.desroches@atmel.com> - 2015-09-15 15:40 +0200

csiph-web