mtd: nand: omap2: Don't call dma_release_channel() if dma_request_chan() failed
Subsystems (2)
PATCH 1/1 mtd: nand: omap2: Don't call dma_release_channel() if dma_request_chan() failed
dma_request_chan() can fail returning an error pointer. In this case prevent calling dma_release_channel() to prevent a ERR_PTR() dereference.
As error path can be called even with no DMA configuration, info->dma can be NULL so don't call dma_release_channel() for that case either.
--- drivers/mtd/nand/omap2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/omap2.c +1 -1
@@ -2169,7 +2169,7 @@ scan_tail:return 0 ; return_error: -if (info->dma) +if (!IS_ERR_OR_NULL (info->dma))dma_release_channel (info->dma);if (nand_chip->ecc.priv) {nand_bch_free (nand_chip->ecc.priv);
Signature · 1 line
2.7.4
Quoted 9 lines · On Mon, 15 Aug 2016 10:47:39 +0300 Roger Quadros <[email protected]> wrote:
dma_request_chan()can fail returning an error pointer. In this case prevent callingdma_release_channel()to prevent aERR_PTR()dereference.As error path can be called even with no DMA configuration,
info->dmacan be NULL so don't calldma_release_channel()for that case either.Fixes de3bfc4a1616: ("mtd: nand: omap2: fix return value check in omap_nand_probe()")Reported-by Dan Carpenter <[email protected]>Signed-off-by Roger Quadros <[email protected]>
Brian, can you apply this fix directly?
Quoted 17 lines
--- drivers/mtd/nand/omap2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/mtd/nand/omap2.c +1
-1@@ -2169,7 +2169,7 @@ scan_tail:return 0 ; return_error: -if (info->dma) +if (!IS_ERR_OR_NULL (info->dma))dma_release_channel (info->dma);if (nand_chip->ecc.priv) {nand_bch_free (nand_chip->ecc.priv);
Brian Norris
AppliedQuoted 9 lines · Boris Brezillon
Quoted 6 lines · On Mon, 15 Aug 2016 10:47:39 +0300 Roger Quadros <[email protected]> wrote:
dma_request_chan()can fail returning an error pointer. In this case prevent callingdma_release_channel()to prevent aERR_PTR()dereference.As error path can be called even with no DMA configuration,
info->dmacan be NULL so don't calldma_release_channel()for that case either.
Quoted 7 lines
Quoted 3 lines
Fixes de3bfc4a1616: ("mtd: nand: omap2: fix return value check in omap_nand_probe()")Reported-by Dan Carpenter <[email protected]>Signed-off-by Roger Quadros <[email protected]>Acked-by Boris Brezillon <[email protected]>Brian, can you apply this fix directly?
Applied to linux-mtd.git