diff options
author | Zhenzhong Duan <zhenzhong.duan@gmail.com> | 2020-06-18 11:21:24 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-06-18 17:46:59 +0100 |
commit | abd42781c3d2155868821f1b947ae45bbc33330d (patch) | |
tree | eb27f5bb3c2d4720aa8832d9c1886eea08a21ed5 /drivers/firewire | |
parent | 35700e221b18fa53401e5f315be90af9e0bbcdca (diff) | |
download | linux-abd42781c3d2155868821f1b947ae45bbc33330d.tar.bz2 |
spi: spidev: fix a race between spidev_release and spidev_remove
Imagine below scene, spidev is referenced after it's freed.
spidev_release() spidev_remove()
...
spin_lock_irq(&spidev->spi_lock);
spidev->spi = NULL;
spin_unlock_irq(&spidev->spi_lock);
mutex_lock(&device_list_lock);
dofree = (spidev->spi == NULL);
if (dofree)
kfree(spidev);
mutex_unlock(&device_list_lock);
mutex_lock(&device_list_lock);
list_del(&spidev->device_entry);
device_destroy(spidev_class, spidev->devt);
clear_bit(MINOR(spidev->devt), minors);
if (spidev->users == 0)
kfree(spidev);
mutex_unlock(&device_list_lock);
Fix it by resetting spidev->spi in device_list_lock's protection.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@gmail.com>
Link: https://lore.kernel.org/r/20200618032125.4650-1-zhenzhong.duan@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/firewire')
0 files changed, 0 insertions, 0 deletions