• Lukas Wunner's avatar
    spi: ar934x: Don't leak SPI master in probe error path · 236924ee
    Lukas Wunner authored
    If the call to devm_spi_register_controller() fails on probe of the
    Qualcomm Atheros AR934x/QCA95xx SPI driver, the spi_controller struct is
    erroneously not freed.  Fix by switching over to the new
    devm_spi_alloc_master() helper.
    
    Moreover, the controller's clock is enabled on probe but not disabled if
    any of the subsequent probe steps fail.
    
    Finally, there's an ordering issue in ar934x_spi_remove() wherein the
    clock is disabled even though the controller is not yet unregistered.
    It is unregistered after ar934x_spi_remove() by the devres framework.
    As long as it is not unregistered, SPI transfers may still be ongoing
    and disabling the clock may break them.  It is not possible to use
    devm_spi_register_controller() in this case, so move to the non-devm
    variant.
    
    All of these bugs have existed since the driver was first introduced,
    so it seems fair to fix them together in a single commit.
    
    Fixes: 047980c5 ("spi: add driver for ar934x spi controller")...
    236924ee
spi-ar934x.c 5.83 KB