* [PATCH 4/5] drivers/char/agp: Eliminate memory leak
@ 2010-08-24 14:39 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 14:39 UTC (permalink / raw)
To: David Airlie, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
alloc_pci_dev allocates some memory, so that memory should be freed before
leaving the function in an error case.
A simplified version of the semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E;
identifier f1;
iterator I;
@@
x = alloc_pci_dev(...);
<... when != x
when != true (x == NULL || ...)
when != if (...) { <+...x...+> }
when != I (...) { <+...x...+> }
(
x == NULL
|
x == E
|
x->f1
)
...>
* return ...;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/char/agp/parisc-agp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 1c12921..e2372b7 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -357,9 +357,10 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
fake_bridge_dev->device = PCI_DEVICE_ID_HP_PCIX_LBA;
bridge->dev = fake_bridge_dev;
- error = agp_add_bridge(bridge);
+ return agp_add_bridge(bridge);
fail:
+ kfree(fake_bridge_dev);
return error;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] drivers/char/agp: Eliminate memory leak
@ 2010-08-24 14:39 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 14:39 UTC (permalink / raw)
To: David Airlie, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
alloc_pci_dev allocates some memory, so that memory should be freed before
leaving the function in an error case.
A simplified version of the semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E;
identifier f1;
iterator I;
@@
x = alloc_pci_dev(...);
<... when != x
when != true (x = NULL || ...)
when != if (...) { <+...x...+> }
when != I (...) { <+...x...+> }
(
x = NULL
|
x = E
|
x->f1
)
...>
* return ...;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/char/agp/parisc-agp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 1c12921..e2372b7 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -357,9 +357,10 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
fake_bridge_dev->device = PCI_DEVICE_ID_HP_PCIX_LBA;
bridge->dev = fake_bridge_dev;
- error = agp_add_bridge(bridge);
+ return agp_add_bridge(bridge);
fail:
+ kfree(fake_bridge_dev);
return error;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
2010-08-24 14:39 ` Julia Lawall
@ 2010-08-24 17:16 ` Dan Carpenter
-1 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-08-24 17:16 UTC (permalink / raw)
To: Julia Lawall; +Cc: David Airlie, linux-kernel, kernel-janitors
On Tue, Aug 24, 2010 at 04:39:29PM +0200, Julia Lawall wrote:
>
> - error = agp_add_bridge(bridge);
> + return agp_add_bridge(bridge);
>
error = agp_add_bridge(bridge);
if (error)
goto fail;
return 0;
> fail:
> + kfree(fake_bridge_dev);
> return error;
> }
>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
@ 2010-08-24 17:16 ` Dan Carpenter
0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2010-08-24 17:16 UTC (permalink / raw)
To: Julia Lawall; +Cc: David Airlie, linux-kernel, kernel-janitors
On Tue, Aug 24, 2010 at 04:39:29PM +0200, Julia Lawall wrote:
>
> - error = agp_add_bridge(bridge);
> + return agp_add_bridge(bridge);
>
error = agp_add_bridge(bridge);
if (error)
goto fail;
return 0;
> fail:
> + kfree(fake_bridge_dev);
> return error;
> }
>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
2010-08-24 17:16 ` Dan Carpenter
@ 2010-08-24 19:46 ` Julia Lawall
-1 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 19:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David Airlie, linux-kernel, kernel-janitors
On Tue, 24 Aug 2010, Dan Carpenter wrote:
> On Tue, Aug 24, 2010 at 04:39:29PM +0200, Julia Lawall wrote:
> >
> > - error = agp_add_bridge(bridge);
> > + return agp_add_bridge(bridge);
> >
>
> error = agp_add_bridge(bridge);
> if (error)
> goto fail;
> return 0;
Good point. I will send another patch.
julia
> > fail:
> > + kfree(fake_bridge_dev);
> > return error;
> > }
> >
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
@ 2010-08-24 19:46 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 19:46 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David Airlie, linux-kernel, kernel-janitors
On Tue, 24 Aug 2010, Dan Carpenter wrote:
> On Tue, Aug 24, 2010 at 04:39:29PM +0200, Julia Lawall wrote:
> >
> > - error = agp_add_bridge(bridge);
> > + return agp_add_bridge(bridge);
> >
>
> error = agp_add_bridge(bridge);
> if (error)
> goto fail;
> return 0;
Good point. I will send another patch.
julia
> > fail:
> > + kfree(fake_bridge_dev);
> > return error;
> > }
> >
>
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
2010-08-24 17:16 ` Dan Carpenter
@ 2010-08-24 20:20 ` Julia Lawall
-1 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 20:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David Airlie, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
alloc_pci_dev allocates some memory, so that memory should be freed before
leaving the function in an error case.
A simplified version of the semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E;
identifier f1;
iterator I;
@@
x = alloc_pci_dev(...);
<... when != x
when != true (x == NULL || ...)
when != if (...) { <+...x...+> }
when != I (...) { <+...x...+> }
(
x == NULL
|
x == E
|
x->f1
)
...>
* return ...;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/char/agp/parisc-agp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 1c12921..17e380f 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -358,8 +358,12 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
bridge->dev = fake_bridge_dev;
error = agp_add_bridge(bridge);
+ if (error)
+ goto fail;
+ return 0;
fail:
+ kfree(fake_bridge_dev);
return error;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 4/5] drivers/char/agp: Eliminate memory leak
@ 2010-08-24 20:20 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-24 20:20 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David Airlie, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
alloc_pci_dev allocates some memory, so that memory should be freed before
leaving the function in an error case.
A simplified version of the semantic match that finds this problem is:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
local idexpression x;
expression E;
identifier f1;
iterator I;
@@
x = alloc_pci_dev(...);
<... when != x
when != true (x = NULL || ...)
when != if (...) { <+...x...+> }
when != I (...) { <+...x...+> }
(
x = NULL
|
x = E
|
x->f1
)
...>
* return ...;
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
drivers/char/agp/parisc-agp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index 1c12921..17e380f 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -358,8 +358,12 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
bridge->dev = fake_bridge_dev;
error = agp_add_bridge(bridge);
+ if (error)
+ goto fail;
+ return 0;
fail:
+ kfree(fake_bridge_dev);
return error;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-08-24 20:20 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 14:39 [PATCH 4/5] drivers/char/agp: Eliminate memory leak Julia Lawall
2010-08-24 14:39 ` Julia Lawall
2010-08-24 17:16 ` Dan Carpenter
2010-08-24 17:16 ` Dan Carpenter
2010-08-24 19:46 ` Julia Lawall
2010-08-24 19:46 ` Julia Lawall
2010-08-24 20:20 ` Julia Lawall
2010-08-24 20:20 ` Julia Lawall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.