mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 13:27:06 +09:00
Revert "spi: Fix use-after-free with devm_spi_alloc_*"
This reverts commitc7fabe372awhich is commit794aaf0144upstream as it breaks the kabi. This should not be needed for android devices as they do not remove SPI devices under normal operation. Bug: 161946584 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I0909978867a4e4e7304fd0d21ebff77c35468cd3
This commit is contained in:
@@ -2481,7 +2481,6 @@ struct spi_controller *__devm_spi_alloc_controller(struct device *dev,
|
|||||||
|
|
||||||
ctlr = __spi_alloc_controller(dev, size, slave);
|
ctlr = __spi_alloc_controller(dev, size, slave);
|
||||||
if (ctlr) {
|
if (ctlr) {
|
||||||
ctlr->devm_allocated = true;
|
|
||||||
*ptr = ctlr;
|
*ptr = ctlr;
|
||||||
devres_add(dev, ptr);
|
devres_add(dev, ptr);
|
||||||
} else {
|
} else {
|
||||||
@@ -2828,6 +2827,11 @@ int devm_spi_register_controller(struct device *dev,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(devm_spi_register_controller);
|
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)
|
static int __unregister(struct device *dev, void *null)
|
||||||
{
|
{
|
||||||
spi_unregister_device(to_spi_device(dev));
|
spi_unregister_device(to_spi_device(dev));
|
||||||
@@ -2874,7 +2878,8 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
|||||||
/* Release the last reference on the controller if its driver
|
/* Release the last reference on the controller if its driver
|
||||||
* has not yet been converted to devm_spi_alloc_master/slave().
|
* 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);
|
put_device(&ctlr->dev);
|
||||||
|
|
||||||
/* free bus id */
|
/* free bus id */
|
||||||
|
|||||||
@@ -511,9 +511,6 @@ struct spi_controller {
|
|||||||
|
|
||||||
#define SPI_MASTER_GPIO_SS BIT(5) /* GPIO CS must select slave */
|
#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 */
|
/* flag indicating this is an SPI slave controller */
|
||||||
bool slave;
|
bool slave;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user