Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ff7a6bc authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Revert "spi: Fix use-after-free with devm_spi_alloc_*"



This reverts commit 28a55290 which is
commit 794aaf01444d4e765e2b067cba01cc69c1c68ed9 upstream.

It breaks the abi for SPI drivers and shouldn't be a problem for Android
devices.

Bug: 161946584
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Change-Id: I6bfd496ebbdcc490058e9e6c29ab29b8fee57b3e
parent dd4d5fdb
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2084,7 +2084,6 @@ struct spi_controller *__devm_spi_alloc_controller(struct device *dev,

	ctlr = __spi_alloc_controller(dev, size, slave);
	if (ctlr) {
		ctlr->devm_allocated = true;
		*ptr = ctlr;
		devres_add(dev, ptr);
	} else {
@@ -2345,6 +2344,11 @@ int devm_spi_register_controller(struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_spi_register_controller);

static int devm_spi_match_controller(struct device *dev, void *res, void *ctlr)
{
	return *(struct spi_controller **)res == ctlr;
}

static int __unregister(struct device *dev, void *null)
{
	spi_unregister_device(to_spi_device(dev));
@@ -2391,7 +2395,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
	/* Release the last reference on the controller if its driver
	 * has not yet been converted to devm_spi_alloc_master/slave().
	 */
	if (!ctlr->devm_allocated)
	if (!devres_find(ctlr->dev.parent, devm_spi_release_controller,
			 devm_spi_match_controller, ctlr))
		put_device(&ctlr->dev);

	/* free bus id */
+0 −3
Original line number Diff line number Diff line
@@ -450,9 +450,6 @@ struct spi_controller {

#define SPI_MASTER_GPIO_SS		BIT(5)	/* GPIO CS must select slave */

	/* flag indicating this is a non-devres managed controller */
	bool			devm_allocated;

	/* flag indicating this is an SPI slave controller */
	bool			slave;