Skip to contentSkip to conversation

dw-mmc: prevent the Null pointer dereference for dma_ops

PATCH In review Jaehoon Chung 3 participants 3 messages Apr 18, 2012 – Apr 19, 2012

Subsystems (2)
lore
Share & tools
lore

Jaehoon Chung

author maintainer
#0 lore raw

PATCH 1/1 dw-mmc: prevent the Null pointer dereference for dma_ops

Now, dma_ops is assumed that use the IDMAC. But if dma_ops is assigned the pdata->dma_ops, We didn't ensure that callback function is defined.

If anything of callback didn't define, then should be run the PIO mode.

---
 drivers/mmc/host/dw_mmc.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/dw_mmc.c +2 -1
index f3b0fcd..bab9ead 100644
@@ -1881,7 +1881,8 @@ static void dw_mci_init_dma(struct dw_mci *host)
 	if (!host->dma_ops)
 		goto no_dma;
 
-	if (host->dma_ops->init) {
+	if (host->dma_ops->init && host->dma_ops->start &&
+			host->dma_ops->stop && host->dma_ops->cleanup) {
 		if (host->dma_ops->init(host)) {
 			dev_err(&host->dev, "%s: Unable to initialize "
 				"DMA Controller.\n", __func__);
Signature · 1 line
1.7.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jaehoon Chung

Now, dma_ops is assumed that use the IDMAC. But if dma_ops is assigned the pdata->dma_ops, We didn't ensure that callback function is defined.

If anything of callback didn't define, then should be run the PIO mode.

---
 drivers/mmc/host/dw_mmc.c |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)

This looks ok.

#2 lore raw

Hi,

Quoted 13 lines · Will Newton
Quoted 11 lines · Jaehoon Chung

Now, dma_ops is assumed that use the IDMAC. But if dma_ops is assigned the pdata->dma_ops, We didn't ensure that callback function is defined.

If anything of callback didn't define, then should be run the PIO mode.

---
 drivers/mmc/host/dw_mmc.c |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
Quoted 3 lines

This looks ok.

Thanks, pushed to mmc-next for 3.5.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child