Skip to content

Commit

Permalink
driver core: bus: Fix a potential double free
Browse files Browse the repository at this point in the history
The .release function of driver_ktype is 'driver_release()'.
This function frees the container_of this kobject.

So, this memory must not be freed explicitly in the error handling path of
'bus_add_driver()'. Otherwise a double free will occur.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
tititiou36 authored and gregkh committed Aug 31, 2017
1 parent 7521621 commit 0f9b011
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 @@ -698,7 +698,7 @@ int bus_add_driver(struct device_driver *drv)

out_unregister:
kobject_put(&priv->kobj);
kfree(drv->p);
/* drv->p is freed in driver_release() */
drv->p = NULL;
out_put_bus:
bus_put(bus);
Expand Down

0 comments on commit 0f9b011

Please sign in to comment.