Skip to contentSkip to conversation

arm: davinci: fix edma dmaengine induced null pointer dereference on da830

PATCH New Matt Porter 3 participants 3 messages Mar 5, 2013 – Mar 12, 2013

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

PATCH v2 1/1 arm: davinci: fix edma dmaengine induced null pointer dereference on da830

This adds additional error checking to the private edma api implementation to catch the case where the edma_alloc_slot() has an invalid controller parameter. The edma dmaengine wrapper driver relies on this condition being handled in order to avoid setting up a second edma dmaengine instance on DA830.

Verfied using a DA850 with the second EDMA controller platform instance removed to simulate a DA830 which only has a single EDMA controller.

Cc stable at vger.kernel.org # v3.7.x+

---
v2: Move error check out of conditional to catch all cases

 arch/arm/mach-davinci/dma.c |    3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-davinci/dma.c +3 -0
index a685e97..45b7c71 100644
@@ -743,6 +743,9 @@ EXPORT_SYMBOL(edma_free_channel);
  */
 int edma_alloc_slot(unsigned ctlr, int slot)
 {
+	if (!edma_cc[ctlr])
+		return -EINVAL;
+
 	if (slot >= 0)
 		slot = EDMA_CHAN_SLOT(slot);
 
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 arm: davinci: fix edma dmaengine induced null pointer dereference on da830

Quoted 23 lines · On Tue, 5 Mar 2013 10:58:22 -0500 Matt Porter <[email protected]> wrote:

This adds additional error checking to the private edma api implementation to catch the case where the edma_alloc_slot() has an invalid controller parameter. The edma dmaengine wrapper driver relies on this condition being handled in order to avoid setting up a second edma dmaengine instance on DA830.

Verfied using a DA850 with the second EDMA controller platform instance removed to simulate a DA830 which only has a single EDMA controller.

Cc stable at vger.kernel.org # v3.7.x+

---
v2: Move error check out of conditional to catch all cases

 arch/arm/mach-davinci/dma.c |    3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-davinci/dma.c +0 -0
index a685e97..45b7c71 100644

arch/arm/mach-davinci/dma.c EXPORT_SYMBOL(edma_free_channel); · line 751

Quoted 9 lines
arch/arm/mach-davinci/dma.c +3 -0
@@ -743,6 +743,9 @@ EXPORT_SYMBOL(edma_free_channel);
  */
 int edma_alloc_slot(unsigned ctlr, int slot)
 {
+	if (!edma_cc[ctlr])
+		return -EINVAL;
+
 	if (slot >= 0)
 		slot = EDMA_CHAN_SLOT(slot);
 

On the TI AM1707 based custom board:

#2 lore raw

PATCH v2 1/1 arm: davinci: fix edma dmaengine induced null pointer dereference on da830

Quoted 38 lines · Tomas Novotny
Quoted 23 lines · On Tue, 5 Mar 2013 10:58:22 -0500 Matt Porter <[email protected]> wrote:

This adds additional error checking to the private edma api implementation to catch the case where the edma_alloc_slot() has an invalid controller parameter. The edma dmaengine wrapper driver relies on this condition being handled in order to avoid setting up a second edma dmaengine instance on DA830.

Verfied using a DA850 with the second EDMA controller platform instance removed to simulate a DA830 which only has a single EDMA controller.

Cc stable at vger.kernel.org # v3.7.x+

---
v2: Move error check out of conditional to catch all cases

 arch/arm/mach-davinci/dma.c |    3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-davinci/dma.c +0 -0
index a685e97..45b7c71 100644

arch/arm/mach-davinci/dma.c EXPORT_SYMBOL(edma_free_channel); · line 751

Quoted 9 lines
arch/arm/mach-davinci/dma.c +3 -0
@@ -743,6 +743,9 @@ EXPORT_SYMBOL(edma_free_channel);
  */
 int edma_alloc_slot(unsigned ctlr, int slot)
 {
+	if (!edma_cc[ctlr])
+		return -EINVAL;
+
 	if (slot >= 0)
 		slot = EDMA_CHAN_SLOT(slot);
 

On the TI AM1707 based custom board:

Quoted 1 line

I tested it on DA830 EVM. Queuing this for v3.9-rc

Thanks,
Sekhar