spi: spidev: fix possible NULL dereference
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Thu, 10 Sep 2015 11:18:13 +0000 (16:48 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Oct 2015 21:43:15 +0000 (14:43 -0700)
commitf72f5774c30418cf802a8964398bbc102d08abe5
tree3f84261ae1bd97558760d2c7d16492cf13022565
parent52b5970ab83c557628b91382914e5d0dac5c4c11
spi: spidev: fix possible NULL dereference

commit dd85ebf681ef0ee1fc985c353dd45e8b53b5dc1e upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spidev.c