linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pxa2xx_spi: Fix race condition in stop_queue()
@ 2011-03-13 22:27 Vasily Khoruzhick
  2011-03-31 21:02 ` Vasily Khoruzhick
  2011-04-01  7:26 ` Eric Miao
  0 siblings, 2 replies; 13+ messages in thread
From: Vasily Khoruzhick @ 2011-03-13 22:27 UTC (permalink / raw)
  To: linux-arm-kernel

There's a race condition in stop_queue(),
if drv_data->queue is empty, but drv_data->busy is still set
(or opposite situation) stop_queue will return -EBUSY.
So fix loop condition to check that both drv_data->queue is empty
and drv_data->busy is not set.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 drivers/spi/pxa2xx_spi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index a429b01..3aa7820 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1493,7 +1493,7 @@ static int stop_queue(struct driver_data *drv_data)
 	 * execution path (pump_messages) would be required to call wake_up or
 	 * friends on every SPI message. Do this instead */
 	drv_data->run = QUEUE_STOPPED;
-	while (!list_empty(&drv_data->queue) && drv_data->busy && limit--) {
+	while ((!list_empty(&drv_data->queue) || drv_data->busy) && limit--) {
 		spin_unlock_irqrestore(&drv_data->lock, flags);
 		msleep(10);
 		spin_lock_irqsave(&drv_data->lock, flags);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-04-07 18:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-13 22:27 [PATCH] pxa2xx_spi: Fix race condition in stop_queue() Vasily Khoruzhick
2011-03-31 21:02 ` Vasily Khoruzhick
2011-04-01  7:26 ` Eric Miao
2011-04-01 10:03   ` Vasily Khoruzhick
2011-04-04 17:35     ` Mike Frysinger
2011-04-04 17:47       ` Vasily Khoruzhick
2011-04-05  3:21         ` Eric Miao
2011-04-06 14:46           ` Vasily Khoruzhick
2011-04-06 14:49             ` [PATCH] spi: " Vasily Khoruzhick
2011-04-07  6:01               ` Eric Miao
2011-04-07  6:12               ` Mike Frysinger
2011-04-07 18:18               ` Grant Likely
2011-04-07  4:58             ` [PATCH] pxa2xx_spi: " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).