spi: don't lock the bus in __spi_pump_messages if it is already locked

A patch from »spi: don't lock the bus in __spi_pump_messages if it is already locked« in state Mainline for linux-kernel

From: Heiko Stuebner <heiko@...> Date: Fri, 18 Mar 2016 00:12:03 +0100

Commit-Message

External users may use spi_bus_lock to get exclusive access. This will also grab the bus_lock_mutex and may therefore result in a deadlock if __spi_pump_messages also tries to get the mutex. Fixes: 49023d2e4ead ("spi: core: Fix deadlock when sending messages") Signed-off-by: Heiko Stuebner <heiko@...>

Patch-Comment

drivers/spi/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Statistics

  • 2 lines added
  • 2 lines removed

Changes

------------------------------ drivers/spi/spi.c -------------------------------
index de2f2f9..62f962b 100644
@@ -1160,7 +1160,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
}
}
- if (!bus_locked)
+ if (!bus_locked && !master->bus_lock_flag)
mutex_lock(&master->bus_lock_mutex);
trace_spi_message_start(master->cur_msg);
@@ -1192,7 +1192,7 @@ static void __spi_pump_messages(struct spi_master *master, bool in_kthread,
}
out:
- if (!bus_locked)
+ if (!bus_locked && !master->bus_lock_flag)
mutex_unlock(&master->bus_lock_mutex);
/* Prod the scheduler in case transfer_one() was busy waiting */
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...