Skip to content

Commit 1991a45

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: unregister ECC engine on probe error and device remove
The on-host hardware ECC engine remains registered both when the spi_register_controller() function returns with an error and also on device removal. Change the qcom_spi_probe() function to unregister the engine on the error path, and add the missing unregistering call to qcom_spi_remove() to avoid possible use-after-free issues. Fixes: 7304d19 ("spi: spi-qpic: add driver for QCOM SPI NAND flash Interface") Signed-off-by: Gabor Juhos <[email protected]> Message-ID: <20250903-qpic-snand-unregister-ecceng-v1-1-ef5387b0abdc@gmail.com> Signed-off-by: Mark Brown <[email protected]>
1 parent 4de51e8 commit 1991a45

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/spi/spi-qpic-snand.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,11 +1615,13 @@ static int qcom_spi_probe(struct platform_device *pdev)
16151615
ret = spi_register_controller(ctlr);
16161616
if (ret) {
16171617
dev_err(&pdev->dev, "spi_register_controller failed.\n");
1618-
goto err_spi_init;
1618+
goto err_register_controller;
16191619
}
16201620

16211621
return 0;
16221622

1623+
err_register_controller:
1624+
nand_ecc_unregister_on_host_hw_engine(&snandc->qspi->ecc_eng);
16231625
err_spi_init:
16241626
qcom_nandc_unalloc(snandc);
16251627
err_snand_alloc:
@@ -1641,7 +1643,7 @@ static void qcom_spi_remove(struct platform_device *pdev)
16411643
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
16421644

16431645
spi_unregister_controller(ctlr);
1644-
1646+
nand_ecc_unregister_on_host_hw_engine(&snandc->qspi->ecc_eng);
16451647
qcom_nandc_unalloc(snandc);
16461648

16471649
clk_disable_unprepare(snandc->aon_clk);

0 commit comments

Comments
 (0)