Skip to contentSkip to conversation

dmaengine: sh: fix some NULL dereferences

PATCH Applied Dan Carpenter 2 participants 2 messages Aug 27, 2021 – Aug 31, 2021

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

PATCH 1/1 dmaengine: sh: fix some NULL dereferences

The dma_free_coherent() function needs a valid device pointer or it will crash.

Fixes 550c591a89a1 ("dmaengine: sh: Add DMAC driver for RZ/G2L SoC")

---
This means that remove() has not been tested.

 drivers/dma/sh/rz-dmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/sh/rz-dmac.c +2 -2
index 11986a8d22fc..7c1db6a5b365 100644
@@ -921,7 +921,7 @@ static int rz_dmac_probe(struct platform_device *pdev)
 	for (i = 0; i < channel_num; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
 
-		dma_free_coherent(NULL,
+		dma_free_coherent(&pdev->dev,
 				  sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
 				  channel->lmdesc.base,
 				  channel->lmdesc.base_dma);
@@ -938,7 +938,7 @@ static int rz_dmac_remove(struct platform_device *pdev)
 	for (i = 0; i < dmac->n_channels; i++) {
 		struct rz_dmac_chan *channel = &dmac->channels[i];
 
-		dma_free_coherent(NULL,
+		dma_free_coherent(&pdev->dev,
 				  sizeof(struct rz_lmdesc) * DMAC_NR_LMDESC,
 				  channel->lmdesc.base,
 				  channel->lmdesc.base_dma);
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 2 lines · Dan Carpenter

The dma_free_coherent() function needs a valid device pointer or it will crash.

Applied, thanks

Signature · 1 line
~Vinod