mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
Some rc device drivers have a race condition between rc_unregister_device() and irq or urb callbacks. This is because rc_unregister_device() does two things, it marks the device as unregistered so no new commands can be issued and then it calls rc_free_device(). This means the driver has no chance to cancel any pending urb callbacks or interrupts after the device has been marked as unregistered. Those callbacks may access struct rc_dev or its members (e.g. struct ir_raw_event_ctrl), which have been freed by rc_free_device(). This change removes the implicit call to rc_free_device() from rc_unregister_device(). This means that device drivers can call rc_unregister_device() in their remove or disconnect function, then cancel all the urbs and interrupts before explicitly calling rc_free_device(). Note this is an alternative fix for an issue found by Haotian Zhang, see the Closes: tags. Reported-by: Haotian Zhang <[email protected]> Closes: https://lore.kernel.org/linux-media/[email protected]/ Closes: https://lore.kernel.org/linux-media/[email protected]/ Closes: https://lore.kernel.org/linux-media/[email protected]/ Closes: https://lore.kernel.org/linux-media/[email protected]/ Reviewed-by: Patrice Chotard <[email protected]> Signed-off-by: Sean Young <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>