Skip to content

Commit 1875ed8

Browse files
tititiou36gregkh
authored andcommitted
driver core: bus: Fix a potential double free
commit 0f9b011d3321ca1079c7a46c18cb1956fbdb7bcb upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f3584d5 commit 1875ed8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/base/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ int bus_add_driver(struct device_driver *drv)
737737

738738
out_unregister:
739739
kobject_put(&priv->kobj);
740-
kfree(drv->p);
740+
/* drv->p is freed in driver_release() */
741741
drv->p = NULL;
742742
out_put_bus:
743743
bus_put(bus);

0 commit comments

Comments
 (0)