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

Felix Gu
2026-03-09T17:14:38Z

On Mon, Mar 9, 2026 at 8:29 PM Mark Brown <broonie@kernel.org> wrote:
>
> 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.

Hi Mark,
Thanks for the review, I will fix it in V2.

Best regards,
Felix