lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  4 May 2021 20:14:16 -0700
From:   Saravana Kannan <saravanak@...gle.com>
To:     Mark Brown <broonie@...nel.org>,
        Saravana Kannan <saravanak@...gle.com>
Cc:     Lukas Wunner <lukas@...ner.de>, kernel-team@...roid.com,
        linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v1] spi: Don't have controller clean up spi device before
 driver unbind

When a spi device is unregistered and triggers a driver unbind, the
driver might need to access the spi device. So, don't have the
controller clean up the spi device before the driver is unbound. Clean
up the spi device after the driver is unbound.

Fixes: c7299fea6769 ("spi: Fix spi device unregister flow")
Reported-by: Lukas Wunner <lukas@...ner.de>
Signed-off-by: Saravana Kannan <saravanak@...gle.com>
---
Lukas,

Can you test this out please?

Thanks,
Saravana

 drivers/spi/spi.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 2350d131871b..b856f4a1e3a4 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -401,6 +401,12 @@ static int spi_probe(struct device *dev)
 	return ret;
 }
 
+static void spi_cleanup(struct spi_device *spi)
+{
+	if (spi->controller->cleanup)
+		spi->controller->cleanup(spi);
+}
+
 static int spi_remove(struct device *dev)
 {
 	const struct spi_driver		*sdrv = to_spi_driver(dev->driver);
@@ -415,6 +421,7 @@ static int spi_remove(struct device *dev)
 				 ERR_PTR(ret));
 	}
 
+	spi_cleanup(to_spi_device(dev));
 	dev_pm_domain_detach(dev, true);
 
 	return 0;
@@ -554,12 +561,6 @@ static int spi_dev_check(struct device *dev, void *data)
 	return 0;
 }
 
-static void spi_cleanup(struct spi_device *spi)
-{
-	if (spi->controller->cleanup)
-		spi->controller->cleanup(spi);
-}
-
 /**
  * spi_add_device - Add spi_device allocated with spi_alloc_device
  * @spi: spi_device to register
@@ -714,8 +715,6 @@ void spi_unregister_device(struct spi_device *spi)
 	if (!spi)
 		return;
 
-	spi_cleanup(spi);
-
 	if (spi->dev.of_node) {
 		of_node_clear_flag(spi->dev.of_node, OF_POPULATED);
 		of_node_put(spi->dev.of_node);
-- 
2.31.1.527.g47e6f16901-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ