Commit dd85ebf6 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Mark Brown

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: 91690516 ("spi: spidev: Don't mangle max_speed_hz in underlying spi device")
Signed-off-by: default avatarSudip Mukherjee <sudip@vectorindia.org>
Reviewed-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Tested-by: default avatarJarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bc0195aa
......@@ -651,6 +651,7 @@ static int spidev_release(struct inode *inode, struct file *filp)
kfree(spidev->rx_buffer);
spidev->rx_buffer = NULL;
if (spidev->spi)
spidev->speed_hz = spidev->spi->max_speed_hz;
/* ... after we unbound from the underlying device? */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment