diff options
author | Kevin Winchester <kjwinchester@gmail.com> | 2009-11-17 17:38:45 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-01-11 00:09:01 -0500 |
commit | 3f50b0222e4c6ac59a5c4819f8be0fa500970381 (patch) | |
tree | f7a5dbfd36457cb77450d9668768a5cc09bc3d0d /drivers/char | |
parent | 22763c5cf3690a681551162c15d34d935308c8d7 (diff) |
agp: correct missing cleanup on error in agp_add_bridge
While investigating a kmemleak detected leak, I encountered the
agp_add_bridge function. It appears to be responsible for freeing
the agp_bridge_data in the case of a failure, but it is only doing
so for some errors.
Fix it to always free the bridge data if a failure condition is
encountered.
Signed-off-by: Kevin Winchester <kjwinchester@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/agp/backend.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index a56ca080e108..c3ab46da51a3 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -285,18 +285,22 @@ int agp_add_bridge(struct agp_bridge_data *bridge) | |||
285 | { | 285 | { |
286 | int error; | 286 | int error; |
287 | 287 | ||
288 | if (agp_off) | 288 | if (agp_off) { |
289 | return -ENODEV; | 289 | error = -ENODEV; |
290 | goto err_put_bridge; | ||
291 | } | ||
290 | 292 | ||
291 | if (!bridge->dev) { | 293 | if (!bridge->dev) { |
292 | printk (KERN_DEBUG PFX "Erk, registering with no pci_dev!\n"); | 294 | printk (KERN_DEBUG PFX "Erk, registering with no pci_dev!\n"); |
293 | return -EINVAL; | 295 | error = -EINVAL; |
296 | goto err_put_bridge; | ||
294 | } | 297 | } |
295 | 298 | ||
296 | /* Grab reference on the chipset driver. */ | 299 | /* Grab reference on the chipset driver. */ |
297 | if (!try_module_get(bridge->driver->owner)) { | 300 | if (!try_module_get(bridge->driver->owner)) { |
298 | dev_info(&bridge->dev->dev, "can't lock chipset driver\n"); | 301 | dev_info(&bridge->dev->dev, "can't lock chipset driver\n"); |
299 | return -EINVAL; | 302 | error = -EINVAL; |
303 | goto err_put_bridge; | ||
300 | } | 304 | } |
301 | 305 | ||
302 | error = agp_backend_initialize(bridge); | 306 | error = agp_backend_initialize(bridge); |
@@ -326,6 +330,7 @@ frontend_err: | |||
326 | agp_backend_cleanup(bridge); | 330 | agp_backend_cleanup(bridge); |
327 | err_out: | 331 | err_out: |
328 | module_put(bridge->driver->owner); | 332 | module_put(bridge->driver->owner); |
333 | err_put_bridge: | ||
329 | agp_put_bridge(bridge); | 334 | agp_put_bridge(bridge); |
330 | return error; | 335 | return error; |
331 | } | 336 | } |