Home
last modified time | relevance | path

Searched hist:c7299fea67696db5bd09d924d1f1080d894f92ef (Results 1 – 1 of 1) sorted by relevance

/linux/drivers/spi/
H A Dspi.cdiff c7299fea67696db5bd09d924d1f1080d894f92ef Tue Apr 27 01:56:38 CEST 2021 Saravana Kannan <saravanak@google.com> spi: Fix spi device unregister flow

When an SPI device is unregistered, the spi->controller->cleanup() is
called in the device's release callback. That's wrong for a couple of
reasons:

1. spi_dev_put() can be called before spi_add_device() is called. And
it's spi_add_device() that calls spi_setup(). This will cause clean()
to get called without the spi device ever being setup.

2. There's no guarantee that the controller's driver would be present by
the time the spi device's release function gets called.

3. It also causes "sleeping in atomic context" stack dump[1] when device
link deletion code does a put_device() on the spi device.

Fix these issues by simply moving the cleanup from the device release
callback to the actual spi_unregister_device() function.

[1] - https://lore.kernel.org/lkml/CAHp75Vc=FCGcUyS0v6fnxme2YJ+qD+Y-hQDQLa2JhWNON9VmsQ@mail.gmail.com/

Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20210426235638.1285530-1-saravanak@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>