mei: bus: fix device leak
Subsystems (2)
Alexander Usyskin
maintainerThe bus rescan function creates bus devices for all clients. The fixup routine is executed on all devices, unneeded devices are removed and fully initialized once set is_added flag to 1.
If link to firmware is reset right after all devices are initialized, but before fixup is executed, the rescan tries to remove devices.
The is_added flag is not set and the mei_cl_bus_dev_destroy returns prematurely.
Allow to clean up device when is_added flag is unset to account for above scenario.
--- drivers/misc/mei/bus.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/misc/mei/bus.c +4 -7
@@ -1430,17 +1430,14 @@ static void mei_cl_bus_dev_stop(struct mei_cl_device *cldev)*/ static void mei_cl_bus_dev_destroy (struct mei_cl_device *cldev) { -WARN_ON (!mutex_is_locked (&cldev->bus->cl_bus_lock)); -if (!cldev->is_added) -return ; - -device_del (&cldev->dev); +if (cldev->is_added) { +device_del (&cldev->dev); + cldev->is_added =0 ; + }list_del_init (&cldev->bus_list); - - cldev->is_added =0 ;put_device (&cldev->dev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerQuoted 13 lines · Alexander Usyskin
The bus rescan function creates bus devices for all clients. The fixup routine is executed on all devices, unneeded devices are removed and fully initialized once set
is_addedflag to 1.If link to firmware is reset right after all devices are initialized, but before fixup is executed, the rescan tries to remove devices.
Theis_addedflag is not set and themei_cl_bus_dev_destroyreturns prematurely.
Allow to clean up device whenis_addedflag is unset to account for above scenario.
Quoted 1 line
Signed-off-by Alexander Usyskin <[email protected]>
What commit id does this fix?
thanks,
greg k-h
Usyskin, Alexander
maintainerQuoted 16 lines
Subject: Re: [char-misc-next] mei: bus: fix device leak
Quoted 13 lines · Alexander Usyskin
The bus rescan function creates bus devices for all clients. The fixup routine is executed on all devices, unneeded devices are removed and fully initialized once set
is_addedflag to 1.If link to firmware is reset right after all devices are initialized, but before fixup is executed, the rescan tries to remove devices.
Theis_addedflag is not set and themei_cl_bus_dev_destroyreturns prematurely.
Allow to clean up device whenis_addedflag is unset to account for above scenario.
Quoted 7 lines
Quoted 1 line
Signed-off-by Alexander Usyskin <[email protected]>What commit id does this fix?
thanks,
greg k-h
This is the one that introduces this function:
commit 6009595a66e4 ("mei: bus: link client devices instead of host clients")
Will send v2 with Fixes tag.
- -
Thanks,
Sasha