From patchwork Thu Nov 27 12:19:49 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 11176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 09E28DDD0C for ; Thu, 27 Nov 2008 23:21:45 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1L5fqg-0002Mg-Jq; Thu, 27 Nov 2008 12:19:58 +0000 Received: from mgw1.diku.dk ([130.225.96.91]) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1L5fqd-0002M7-16 for linux-mtd@lists.infradead.org; Thu, 27 Nov 2008 12:19:56 +0000 Received: from localhost (localhost [127.0.0.1]) by mgw1.diku.dk (Postfix) with ESMTP id 1A75A52C384; Thu, 27 Nov 2008 13:19:52 +0100 (CET) X-Virus-Scanned: amavisd-new at diku.dk Received: from mgw1.diku.dk ([127.0.0.1]) by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lnygTN74KUU4; Thu, 27 Nov 2008 13:19:49 +0100 (CET) Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140]) by mgw1.diku.dk (Postfix) with ESMTP id CC12752C311; Thu, 27 Nov 2008 13:19:49 +0100 (CET) Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4]) by nhugin.diku.dk (Postfix) with ESMTP id 3FF556DFAB2; Thu, 27 Nov 2008 13:17:40 +0100 (CET) Received: by pc-004.diku.dk (Postfix, from userid 3767) id B37B09C4E8; Thu, 27 Nov 2008 13:19:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by pc-004.diku.dk (Postfix) with ESMTP id B23469C45A; Thu, 27 Nov 2008 13:19:49 +0100 (CET) Date: Thu, 27 Nov 2008 13:19:49 +0100 (CET) From: Julia Lawall To: dwmw2@infradead.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put Message-ID: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Julia Lawall pci_get_device increments a reference count that should be decremented using pci_dev_put. I have thus added an extra label in the error handling code to do this. I don't know, however, whether there should be a pci_dev_put before the return 0 as well. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S,S1; position p1,p2,p3; expression E,E1; type T,T1; expression *ptr != NULL; @@ ( if ((x@p1 = pci_get_device(...)) == NULL) S | x@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@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@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) // Signed-off-by: Julia Lawall Acked-by: Olof Johansson --- drivers/mtd/nand/pasemi_nand.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c index 75c8990..ceae196 100644 --- a/drivers/mtd/nand/pasemi_nand.c +++ b/drivers/mtd/nand/pasemi_nand.c @@ -144,7 +144,7 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev, if (!request_region(lpcctl, 4, driver_name)) { err = -EBUSY; - goto out_ior; + goto out_pdev; } chip->cmd_ctrl = pasemi_hwcontrol; @@ -176,6 +176,8 @@ static int __devinit pasemi_nand_probe(struct of_device *ofdev, out_lpc: release_region(lpcctl, 4); + out_pdev: + pci_dev_put(pdev); out_ior: iounmap(chip->IO_ADDR_R); out_mtd: