From: Linus Walleij Date: Wed, 13 Nov 2019 01:44:42 +0000 (+0100) Subject: spi: fsl-cpm: Correct the free:ing X-Git-Tag: v5.5-rc1~171^2~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5923243eb3208ea63b5ed7905610039c4ca5201;p=thirdparty%2Fkernel%2Flinux.git spi: fsl-cpm: Correct the free:ing The fsl_spi_cpm_free() function does not make the same checks as the error path in fsl_spi_cpm_init() leading to crashes on error. Cc: Fabio Estevam Reported-by: Christophe Leroy Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20191113014442.12100-1-linus.walleij@linaro.org Signed-off-by: Mark Brown --- diff --git a/drivers/spi/spi-fsl-cpm.c b/drivers/spi/spi-fsl-cpm.c index 858f0544289e6..54ad0ac121e5b 100644 --- a/drivers/spi/spi-fsl-cpm.c +++ b/drivers/spi/spi-fsl-cpm.c @@ -392,7 +392,8 @@ void fsl_spi_cpm_free(struct mpc8xxx_spi *mspi) dma_unmap_single(dev, mspi->dma_dummy_rx, SPI_MRBLR, DMA_FROM_DEVICE); dma_unmap_single(dev, mspi->dma_dummy_tx, PAGE_SIZE, DMA_TO_DEVICE); cpm_muram_free(cpm_muram_offset(mspi->tx_bd)); - cpm_muram_free(cpm_muram_offset(mspi->pram)); + if (!(mspi->flags & SPI_CPM1)) + cpm_muram_free(cpm_muram_offset(mspi->pram)); fsl_spi_free_dummy_rx(); } EXPORT_SYMBOL_GPL(fsl_spi_cpm_free);