diff mbox series

dmaengine: sh: fix some NULL dereferences

Message ID 20210827085410.GA9183@kili (mailing list archive)
State Accepted
Commit 11a427be2c4749954e8b868ef5301dc65ca5a14b
Headers show
Series dmaengine: sh: fix some NULL dereferences | expand

Commit Message

Dan Carpenter Aug. 27, 2021, 8:54 a.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This means that remove() has not been tested.

 drivers/dma/sh/rz-dmac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Vinod Koul Aug. 31, 2021, 4:20 p.m. UTC | #1
On 27-08-21, 11:54, Dan Carpenter wrote:
> The dma_free_coherent() function needs a valid device pointer or it will
> crash.

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 11986a8d22fc..7c1db6a5b365 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -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);