]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
spi: img-spfi: fix potential double release
authorPan Bian <bianpan2016@163.com>
Wed, 6 Nov 2019 02:36:09 +0000 (10:36 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 6 Nov 2019 15:33:39 +0000 (15:33 +0000)
The channels spfi->tx_ch and spfi->rx_ch are not set to NULL after they
are released. As a result, they will be released again, either on the
error handling branch in the same function or in the corresponding
remove function, i.e. img_spfi_remove(). This patch fixes the bug by
setting the two members to NULL.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Link: https://lore.kernel.org/r/1573007769-20131-1-git-send-email-bianpan2016@163.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-img-spfi.c

index 439b01e4a2c8d2c2fb8d435d4104b9d7f3c299b6..f4a8f470aecc2f71ef7e98e71aa23bcc8de2bd43 100644 (file)
@@ -673,6 +673,8 @@ static int img_spfi_probe(struct platform_device *pdev)
                        dma_release_channel(spfi->tx_ch);
                if (spfi->rx_ch)
                        dma_release_channel(spfi->rx_ch);
+               spfi->tx_ch = NULL;
+               spfi->rx_ch = NULL;
                dev_warn(spfi->dev, "Failed to get DMA channels, falling back to PIO mode\n");
        } else {
                master->dma_tx = spfi->tx_ch;