Re: [PATCH] spi: rockchip-sfc: Remove redundant spi_unregister_controller() call

Mark Brown
2026-03-09T12:29:40Z

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]