All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-omap@vger.kernel.org, Santosh Shilimkar <santosh.shilimkar@ti.com>
Subject: [PATCH 01/11] ARM: OMAP: Fix for possible race condition in omap_free_dma()
Date: Tue, 14 Apr 2009 14:49:11 -0700	[thread overview]
Message-ID: <20090414214911.9878.76642.stgit@localhost> (raw)
In-Reply-To: <20090414214638.9878.17987.stgit@localhost>

From: Santosh Shilimkar <santosh.shilimkar@ti.com>

Fix the possible race condition in omap_free_dma(). Function omap_free_dma()
sets the dev_id = -1 and then accesses the channel afterwards to clear it.
But setting the dev_id=-1 makes the channel available for allocation again.
So it is possible someone else can grab it and results are unpredictable.
To avod this DMA channle is cleared first and then the dev_id = -1 is set.

Thanks to McNeil, Sean <sean.mcneil@ti.com> for ointing out this issue.

Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/dma.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 21cc014..7fc8c04 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -760,19 +760,12 @@ void omap_free_dma(int lch)
 {
 	unsigned long flags;
 
-	spin_lock_irqsave(&dma_chan_lock, flags);
 	if (dma_chan[lch].dev_id == -1) {
 		pr_err("omap_dma: trying to free unallocated DMA channel %d\n",
 		       lch);
-		spin_unlock_irqrestore(&dma_chan_lock, flags);
 		return;
 	}
 
-	dma_chan[lch].dev_id = -1;
-	dma_chan[lch].next_lch = -1;
-	dma_chan[lch].callback = NULL;
-	spin_unlock_irqrestore(&dma_chan_lock, flags);
-
 	if (cpu_class_is_omap1()) {
 		/* Disable all DMA interrupts for the channel. */
 		dma_write(0, CICR(lch));
@@ -798,6 +791,12 @@ void omap_free_dma(int lch)
 		dma_write(0, CCR(lch));
 		omap_clear_dma(lch);
 	}
+
+	spin_lock_irqsave(&dma_chan_lock, flags);
+	dma_chan[lch].dev_id = -1;
+	dma_chan[lch].next_lch = -1;
+	dma_chan[lch].callback = NULL;
+	spin_unlock_irqrestore(&dma_chan_lock, flags);
 }
 EXPORT_SYMBOL(omap_free_dma);
 


  reply	other threads:[~2009-04-14 21:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-14 21:47 [PATCH 00/11] Omap fixes for 2.6.30-rc1 Tony Lindgren
2009-04-14 21:49 ` Tony Lindgren [this message]
2009-04-14 21:50 ` [PATCH 02/11] ARM: OMAP: Remove old dead gpio expander code Tony Lindgren
2009-04-14 21:51 ` [PATCH 03/11] ARM: OMAP: MMC: Remove unused power_pin Tony Lindgren
2009-04-14 21:53 ` [PATCH 04/11] ARM: OMAP1: Simplify board-h2 MMC setup Tony Lindgren
2009-04-14 21:54 ` [PATCH 05/11] ARM: OMAP1: Fix mmc_set_power GPIO usage Tony Lindgren
2009-04-14 21:55 ` [PATCH 06/11] ARM: OMAP2: Remove defines and resource init for OMAP24XX EAC Tony Lindgren
2009-04-14 21:57 ` [PATCH 07/11] ARM: OMAP2: possible division by 0 Tony Lindgren
2009-04-14 21:58 ` [PATCH 08/11] ARM: OMAP2/3: GPIO: do not attempt to wake-enable Tony Lindgren
2009-05-18 19:50   ` Hunter, Jon
2009-05-21 15:53     ` Kevin Hilman
2009-04-14 21:59 ` [PATCH 09/11] ARM: OMAP3: remove duplicated #include Tony Lindgren
2009-04-14 22:01 ` [PATCH 10/11] ARM: OMAP3: Fixed spurious IRQ issue for GPIO interrupts Tony Lindgren
2009-04-14 22:02 ` [PATCH 11/11] ARM: OMAP3: Clean up spurious interrupt check logic Tony Lindgren
2009-04-17  1:23 ` git pull request for omap fixes (Re: [PATCH 00/11] Omap fixes for 2.6.30-rc1) Tony Lindgren
2009-04-21  4:57   ` git pull request for omap fixes, v2 " Tony Lindgren
2009-04-21 15:55     ` Tony Lindgren
2009-04-23 18:20       ` git pull request for omap fixes, v3 " Tony Lindgren
2009-04-24 17:53         ` git pull request for omap fixes, v4 " Tony Lindgren
2009-04-24 21:16           ` Russell King - ARM Linux
2009-04-24 21:33             ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090414214911.9878.76642.stgit@localhost \
    --to=tony@atomide.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-omap@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.