提交 3f50b022 编写于 作者: K Kevin Winchester 提交者: Dave Airlie

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: NKevin Winchester <kjwinchester@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NDave Airlie <airlied@redhat.com>
上级 22763c5c
...@@ -285,18 +285,22 @@ int agp_add_bridge(struct agp_bridge_data *bridge) ...@@ -285,18 +285,22 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
{ {
int error; int error;
if (agp_off) if (agp_off) {
return -ENODEV; error = -ENODEV;
goto err_put_bridge;
}
if (!bridge->dev) { if (!bridge->dev) {
printk (KERN_DEBUG PFX "Erk, registering with no pci_dev!\n"); printk (KERN_DEBUG PFX "Erk, registering with no pci_dev!\n");
return -EINVAL; error = -EINVAL;
goto err_put_bridge;
} }
/* Grab reference on the chipset driver. */ /* Grab reference on the chipset driver. */
if (!try_module_get(bridge->driver->owner)) { if (!try_module_get(bridge->driver->owner)) {
dev_info(&bridge->dev->dev, "can't lock chipset driver\n"); dev_info(&bridge->dev->dev, "can't lock chipset driver\n");
return -EINVAL; error = -EINVAL;
goto err_put_bridge;
} }
error = agp_backend_initialize(bridge); error = agp_backend_initialize(bridge);
...@@ -326,6 +330,7 @@ int agp_add_bridge(struct agp_bridge_data *bridge) ...@@ -326,6 +330,7 @@ int agp_add_bridge(struct agp_bridge_data *bridge)
agp_backend_cleanup(bridge); agp_backend_cleanup(bridge);
err_out: err_out:
module_put(bridge->driver->owner); module_put(bridge->driver->owner);
err_put_bridge:
agp_put_bridge(bridge); agp_put_bridge(bridge);
return error; return error;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册