[PATCH] spi: rockchip-sfc: Remove redundant spi_unregister_controller() call
Mark Brown
broonie at kernel.org
Mon Mar 9 05:29:35 PDT 2026
On Thu, Mar 05, 2026 at 11:38:21PM +0800, Felix Gu wrote:
> The driver uses devm_spi_register_controller() for registration, which
> automatically unregisters the controller via devm cleanup when the
> device is removed.
> The manual call to spi_unregister_controller() in the remove() callback
> is therefore redundant and should be removed.
Not just redundant, it'll be a double free.
> - spi_unregister_controller(host);
> dma_unmap_single(&pdev->dev, sfc->dma_buffer, sfc->max_iosize,
> DMA_BIDIRECTIONAL);
> free_pages((unsigned long)sfc->buffer, get_order(sfc->max_iosize));
This does mean that if the device is being force unregistered with
children still present those children might still be submitting SPI
requests while the DMA buffer is unmapped, but in the normal course of
affairs it's more likely that the devices will be unregistered before
the controller. It would be best to either roll back the use of devm or
add a devm based unmap of the buffer here, the current remove function
has correct ordering.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-rockchip/attachments/20260309/d119c34b/attachment.sig>
More information about the Linux-rockchip
mailing list