[3.16.y-ckt stable] Patch "spi: spidev: fix possible NULL dereference" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Mon Oct 26 21:14:44 UTC 2015


This is a note to let you know that I have just added a patch titled

    spi: spidev: fix possible NULL dereference

to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.16.y-queue

This patch is scheduled to be released in version 3.19.8-ckt9.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.16.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From 86b3bf0a8515b566c6f0d0fb6875c1920b4ec26b Mon Sep 17 00:00:00 2001
From: Sudip Mukherjee <sudipm.mukherjee at gmail.com>
Date: Thu, 10 Sep 2015 16:48:13 +0530
Subject: 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 at vectorindia.org>
Reviewed-by: Jarkko Nikula <jarkko.nikula at linux.intel.com>
Tested-by: Jarkko Nikula <jarkko.nikula at linux.intel.com>
Signed-off-by: Mark Brown <broonie at kernel.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 drivers/spi/spidev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 5c85435..e0bec45 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -579,7 +579,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);
--
1.9.1





More information about the kernel-team mailing list