[MTD] [NAND] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed Dec 3 05:59:01 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=d94762989103b5e29938d8a7b0112e72c4633265
Commit:     d94762989103b5e29938d8a7b0112e72c4633265
Parent:     29b65861fbece04cfdf3fee352d5247369131850
Author:     Julia Lawall <julia at diku.dk>
AuthorDate: Mon Dec 1 23:00:55 2008 +0100
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Tue Dec 2 10:45:19 2008 +0000

    [MTD] [NAND] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
    
    pci_get_device increments a reference count that should be decremented
    using pci_dev_put.
    
    The semantic patch that finds the problem is as follows:
    (http://www.emn.fr/x-info/coccinelle/)
    
    // <smpl>
    @r exists@
    local idexpression x;
    statement S,S1;
    position p1,p2,p3;
    expression E,E1;
    type T,T1;
    expression *ptr != NULL;
    @@
    
    (
     if ((x at p1 = pci_get_device(...)) == NULL) S
    |
     x at p1 = pci_get_device(...);
    )
     ... when != pci_dev_put(...,(T)x,...)
         when != if (...) { <+... pci_dev_put(...,(T)x,...) ...+> }
         when != true x == NULL || ...
         when != x = E
         when != E = (T)x
         when any
    (
     if (x == NULL || ...) S1
    |
     if at p2 (...) {
      ... when != pci_dev_put(...,(T1)x,...)
          when != if (...) { <+... pci_dev_put(...,(T1)x,...) ...+> }
          when != x = E1
          when != E1 = (T1)x
    (
      return \(0\|<+...x...+>\|ptr\);
    |
      return at p3 ...;
    )
    }
    )
    
    @ script:python @
    p1 << r.p1;
    p3 << r.p3;
    @@
    
    print "* file: %s pci_get_device: %s return: %s" % (p1[0].file,p1[0].line,p3[0].line)
    // </smpl>
    
    Signed-off-by: Julia Lawall <julia at diku.dk>
    Acked-by: Olof Johansson <olof at lixom.net>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/pasemi_nand.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
index 75c8990..9bd6c9a 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -141,6 +141,7 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev,
 	}
 
 	lpcctl = pci_resource_start(pdev, 0);
+	pci_dev_put(pdev);
 
 	if (!request_region(lpcctl, 4, driver_name)) {
 		err = -EBUSY;



More information about the linux-mtd-cvs mailing list