Skip to content

Commit

Permalink
Revert "spi: fix use-after-free of the add_lock mutex" [5.4.286]
Browse files Browse the repository at this point in the history
This reverts commit 54c2c96eafcfd242e52e932ab54ace4784efe1dd which is
commit 6c53b45c71b4920b5e62f0ea8079a1da382b9434 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: Icce07d26ecdbeb799b479babd47730046b402902
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gregkh authored and psndna88 committed Nov 26, 2024
1 parent c27c16f commit 6e58fa8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2674,21 +2674,21 @@ void spi_unregister_controller(struct spi_controller *ctlr)

device_del(&ctlr->dev);

/* Release the last reference on the controller if its driver
* has not yet been converted to devm_spi_alloc_master/slave().
*/
if (!devres_find(ctlr->dev.parent, devm_spi_release_controller,
devm_spi_match_controller, ctlr))
put_device(&ctlr->dev);

/* free bus id */
mutex_lock(&board_lock);
if (found == ctlr)
idr_remove(&spi_master_idr, id);
mutex_unlock(&board_lock);

if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
mutex_unlock(&ctlr->add_lock);

/* Release the last reference on the controller if its driver
* has not yet been converted to devm_spi_alloc_master/slave().
*/
if (!devres_find(ctlr->dev.parent, devm_spi_release_controller,
devm_spi_match_controller, ctlr))
put_device(&ctlr->dev);
mutex_unlock(&spi_add_lock);
}
EXPORT_SYMBOL_GPL(spi_unregister_controller);

Expand Down

0 comments on commit 6e58fa8

Please sign in to comment.