Skip to content

Commit

Permalink
driver core: Prevent reference to freed memory on error path
Browse files Browse the repository at this point in the history
priv is drv->p. So only free drv->p after we've finished using priv.

Found using a static code analysis tool

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Phil Carmody authored and Greg Kroah-Hartman committed Dec 23, 2009
1 parent e6309e7 commit 99b28f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,9 @@ int bus_add_driver(struct device_driver *drv)
return 0;

out_unregister:
kobject_put(&priv->kobj);
kfree(drv->p);
drv->p = NULL;
kobject_put(&priv->kobj);
out_put_bus:
bus_put(bus);
return error;
Expand Down

0 comments on commit 99b28f1

Please sign in to comment.