From 338e4fab3d41aa14264e10ce505a7c908633cdad Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 20 Oct 2010 15:55:45 -0700 Subject: drivers/char/agp/parisc-agp.c: eliminate memory leak 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/) // @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 ...; // Signed-off-by: Julia Lawall Dan Carpenter Dave Airlie Cc: Helge Deller Cc: "James E.J. Bottomley" Signed-off-by: Andrew Morton Signed-off-by: Kyle McMartin --- drivers/char/agp/parisc-agp.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char/agp') diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index 1c129211302d..17e380f5f818 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; } -- cgit v1.2.2 From 6a915c2bf073743dd31229f1ec2eaa7a2b13c1c3 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Fri, 29 Oct 2010 12:48:01 -0400 Subject: parisc-agp: fix missing slab.h include Commit 338e4fab added a missing kfree if the alloc_pci_dev failed but forgot to include for the definition of kfree. Signed-off-by: Kyle McMartin --- drivers/char/agp/parisc-agp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char/agp') diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index 17e380f5f818..94821ab01c6d 100644 --- a/drivers/char/agp/parisc-agp.c +++ b/drivers/char/agp/parisc-agp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include -- cgit v1.2.2