Skip to contentSkip to conversation

dma: imx-sdma: Save imx_dma_data into sdmac

PATCH Applied Nicolin Chen 2 participants 2 messages Jun 16, 2014 – Jul 25, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: imx-sdma: Save imx_dma_data into sdmac

The filter() function is currently called by xlate() while it transfers imx_dma_data as a local variable to the filter() but releases the data right after returning a DMA channel pointer, which results chan->private pointing an invalid memory space.

So this patch just stores the imx_dma_data into sdmac to make usre the private pointer valid as long as the channel exists.

---
 drivers/dma/imx-sdma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/imx-sdma.c +4 -1
index 19041ce..fc04add 100644
@@ -270,6 +270,7 @@ struct sdma_channel {
 	unsigned int			chn_count;
 	unsigned int			chn_real_count;
 	struct tasklet_struct		tasklet;
+	struct imx_dma_data		data;
 };
 
 #define IMX_DMA_SG_LOOP		BIT(0)
@@ -1402,12 +1403,14 @@ err_dma_alloc:
 
 static bool sdma_filter_fn(struct dma_chan *chan, void *fn_param)
 {
+	struct sdma_channel *sdmac = to_sdma_chan(chan);
 	struct imx_dma_data *data = fn_param;
 
 	if (!imx_dma_is_general_purpose(chan))
 		return false;
 
-	chan->private = data;
+	sdmac->data = *data;
+	chan->private = &sdmac->data;
 
 	return true;
 }
Signature · 1 line
1.8.4
Applied
#1 lore raw
Quoted 7 lines · Nicolin Chen

The filter() function is currently called by xlate() while it transfers imx_dma_data as a local variable to the filter() but releases the data right after returning a DMA channel pointer, which results chan->private pointing an invalid memory space.

So this patch just stores the imx_dma_data into sdmac to make usre the private pointer valid as long as the channel exists.

Applied, thanks

Signature · 1 line
~Vinod