* [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
@ 2008-11-27 12:19 Julia Lawall
2008-12-01 17:43 ` Olof Johansson
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2008-11-27 12:19 UTC (permalink / raw)
To: dwmw2, linux-mtd, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
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/)
// <smpl>
@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)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
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:
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-12-01 17:43 ` Olof Johansson
@ 2008-12-01 17:39 ` Julia Lawall
2008-12-01 18:08 ` Olof Johansson
0 siblings, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2008-12-01 17:39 UTC (permalink / raw)
To: Olof Johansson; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Mon, 1 Dec 2008, Olof Johansson wrote:
> On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> > From: Julia Lawall <julia@diku.dk>
> >
> > 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.
> >
> [...]
>
> > Signed-off-by: Julia Lawall <julia@diku.dk>
>
> Acked-by: Olof Johansson <olof@lixom.net>
Do you know the answer about the return 0?
julia
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-11-27 12:19 [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put Julia Lawall
@ 2008-12-01 17:43 ` Olof Johansson
2008-12-01 17:39 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Olof Johansson @ 2008-12-01 17:43 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> 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.
>
[...]
> Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Olof Johansson <olof@lixom.net>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-12-01 18:08 ` Olof Johansson
@ 2008-12-01 18:03 ` Julia Lawall
2008-12-01 20:11 ` Julia Lawall
1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2008-12-01 18:03 UTC (permalink / raw)
To: Olof Johansson; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Mon, 1 Dec 2008, Olof Johansson wrote:
> On Mon, Dec 01, 2008 at 06:39:01PM +0100, Julia Lawall wrote:
> > On Mon, 1 Dec 2008, Olof Johansson wrote:
> >
> > > On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> > > > From: Julia Lawall <julia@diku.dk>
> > > >
> > > > 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.
> > > >
> > > [...]
> > >
> > > > Signed-off-by: Julia Lawall <julia@diku.dk>
> > >
> > > Acked-by: Olof Johansson <olof@lixom.net>
> >
> > Do you know the answer about the return 0?
>
> Teaches me to read the patch description twice.
>
> Either there or in pasemi_nand_remove(), doesn't matter much to me. Doing
> it before the return 0 is the smaller change.
OK, I will send an adjusted patch shortly.
Thanks,
julia
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-12-01 17:39 ` Julia Lawall
@ 2008-12-01 18:08 ` Olof Johansson
2008-12-01 18:03 ` Julia Lawall
2008-12-01 20:11 ` Julia Lawall
0 siblings, 2 replies; 7+ messages in thread
From: Olof Johansson @ 2008-12-01 18:08 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Mon, Dec 01, 2008 at 06:39:01PM +0100, Julia Lawall wrote:
> On Mon, 1 Dec 2008, Olof Johansson wrote:
>
> > On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> > > From: Julia Lawall <julia@diku.dk>
> > >
> > > 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.
> > >
> > [...]
> >
> > > Signed-off-by: Julia Lawall <julia@diku.dk>
> >
> > Acked-by: Olof Johansson <olof@lixom.net>
>
> Do you know the answer about the return 0?
Teaches me to read the patch description twice.
Either there or in pasemi_nand_remove(), doesn't matter much to me. Doing
it before the return 0 is the smaller change.
-Olof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-12-01 18:08 ` Olof Johansson
2008-12-01 18:03 ` Julia Lawall
@ 2008-12-01 20:11 ` Julia Lawall
2008-12-01 21:57 ` Olof Johansson
1 sibling, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2008-12-01 20:11 UTC (permalink / raw)
To: Olof Johansson; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Mon, 1 Dec 2008, Olof Johansson wrote:
> On Mon, Dec 01, 2008 at 06:39:01PM +0100, Julia Lawall wrote:
> > On Mon, 1 Dec 2008, Olof Johansson wrote:
> >
> > > On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> > > > From: Julia Lawall <julia@diku.dk>
> > > >
> > > > 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.
> > > >
> > > [...]
> > >
> > > > Signed-off-by: Julia Lawall <julia@diku.dk>
> > >
> > > Acked-by: Olof Johansson <olof@lixom.net>
> >
> > Do you know the answer about the return 0?
>
> Teaches me to read the patch description twice.
>
> Either there or in pasemi_nand_remove(), doesn't matter much to me. Doing
> it before the return 0 is the smaller change.
Actually, could pci_dev_put(pdev) be placed right after:
lpcctl = pci_resource_start(pdev, 0);
Then there would only be one, and the rest of the code could go back to
its original form.
julia
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put
2008-12-01 20:11 ` Julia Lawall
@ 2008-12-01 21:57 ` Olof Johansson
0 siblings, 0 replies; 7+ messages in thread
From: Olof Johansson @ 2008-12-01 21:57 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, dwmw2, linux-kernel
On Mon, Dec 01, 2008 at 09:11:09PM +0100, Julia Lawall wrote:
> On Mon, 1 Dec 2008, Olof Johansson wrote:
>
> > On Mon, Dec 01, 2008 at 06:39:01PM +0100, Julia Lawall wrote:
> > > On Mon, 1 Dec 2008, Olof Johansson wrote:
> > >
> > > > On Thu, Nov 27, 2008 at 01:19:49PM +0100, Julia Lawall wrote:
> > > > > From: Julia Lawall <julia@diku.dk>
> > > > >
> > > > > 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.
> > > > >
> > > > [...]
> > > >
> > > > > Signed-off-by: Julia Lawall <julia@diku.dk>
> > > >
> > > > Acked-by: Olof Johansson <olof@lixom.net>
> > >
> > > Do you know the answer about the return 0?
> >
> > Teaches me to read the patch description twice.
> >
> > Either there or in pasemi_nand_remove(), doesn't matter much to me. Doing
> > it before the return 0 is the smaller change.
>
> Actually, could pci_dev_put(pdev) be placed right after:
>
> lpcctl = pci_resource_start(pdev, 0);
>
> Then there would only be one, and the rest of the code could go back to
> its original form.
Yep, even easier.
Thanks for catching this.
-Olof
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-12-01 21:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-27 12:19 [PATCH] drivers/mtd/nand/pasemi_nand.c: Add missing pci_dev_put Julia Lawall
2008-12-01 17:43 ` Olof Johansson
2008-12-01 17:39 ` Julia Lawall
2008-12-01 18:08 ` Olof Johansson
2008-12-01 18:03 ` Julia Lawall
2008-12-01 20:11 ` Julia Lawall
2008-12-01 21:57 ` Olof Johansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox