diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-09-10 14:18:13 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-09-11 15:26:38 +0300 |
commit | dd85ebf681ef0ee1fc985c353dd45e8b53b5dc1e (patch) | |
tree | f98f45ded2eb2d7af97cf59515f30de61c669f5c /drivers/spi/spidev.c | |
parent | bc0195aad0daa2ad5b0d76cce22b167bc3435590 (diff) | |
download | linux-dd85ebf681ef0ee1fc985c353dd45e8b53b5dc1e.tar.xz |
spi: spidev: fix possible NULL dereference
During the last close we are freeing spidev if spidev->spi is NULL, but
just before checking if spidev->spi is NULL we are dereferencing it.
Lets add a check there to avoid the NULL dereference.
Fixes: 9169051617df ("spi: spidev: Don't mangle max_speed_hz in underlying spi device")
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spidev.c')
-rw-r--r-- | drivers/spi/spidev.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index dd616ff0ffc5..e58ca17eb247 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -651,7 +651,8 @@ static int spidev_release(struct inode *inode, struct file *filp) kfree(spidev->rx_buffer); spidev->rx_buffer = NULL; - spidev->speed_hz = spidev->spi->max_speed_hz; + if (spidev->spi) + spidev->speed_hz = spidev->spi->max_speed_hz; /* ... after we unbound from the underlying device? */ spin_lock_irq(&spidev->spi_lock); |