Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: spidev: Hold spi_lock over all defererences of spi in release()

We use the spi_lock spinlock to protect against races between the device
being removed and file operations on the spidev. This means that in the
removal path all references to the device need to be done under lock as
in removal we dropping references to the device.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

+1 -1
+1 -1
drivers/spi/spidev.c
··· 651 651 kfree(spidev->rx_buffer); 652 652 spidev->rx_buffer = NULL; 653 653 654 + spin_lock_irq(&spidev->spi_lock); 654 655 if (spidev->spi) 655 656 spidev->speed_hz = spidev->spi->max_speed_hz; 656 657 657 658 /* ... after we unbound from the underlying device? */ 658 - spin_lock_irq(&spidev->spi_lock); 659 659 dofree = (spidev->spi == NULL); 660 660 spin_unlock_irq(&spidev->spi_lock); 661 661