mtd: nand: omap2: Don't call dma_release_channel() if dma_request_chan() failed

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Aug 29 12:59:01 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=a93295a7e118b5c58391906e47183775b1eb7cb1
Commit:     a93295a7e118b5c58391906e47183775b1eb7cb1
Parent:     29b4817d4018df78086157ea3a55c1d9424a7cfc
Author:     Roger Quadros <rogerq at ti.com>
AuthorDate: Mon Aug 15 10:47:39 2016 +0300
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Mon Aug 29 12:54:39 2016 -0700

    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.
    
    Fixes: de3bfc4a1616: ("mtd: nand: omap2: fix return value check in omap_nand_probe()")
    Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
    Signed-off-by: Roger Quadros <rogerq at ti.com>
    Acked-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/omap2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index a59361c..5513bfd9 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -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);



More information about the linux-mtd-cvs mailing list