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/) // <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> Dan Carpenter <error27@gmail.com> Dave Airlie <airlied@linux.ie> Cc: Helge Deller <deller@gmx.de> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Kyle McMartin <kyle@redhat.com>
This commit is contained in:
		
					parent
					
						
							
								7da1272547
							
						
					
				
			
			
				commit
				
					
						338e4fab3d
					
				
			
		
					 1 changed files with 4 additions and 0 deletions
				
			
		| 
						 | 
					@ -358,8 +358,12 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa)
 | 
				
			||||||
	bridge->dev = fake_bridge_dev;
 | 
						bridge->dev = fake_bridge_dev;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = agp_add_bridge(bridge);
 | 
						error = agp_add_bridge(bridge);
 | 
				
			||||||
 | 
						if (error)
 | 
				
			||||||
 | 
							goto fail;
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fail:
 | 
					fail:
 | 
				
			||||||
 | 
						kfree(fake_bridge_dev);
 | 
				
			||||||
	return error;
 | 
						return error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue