dvb_usbv2_remote_init() initializes d->rc_query_work only when the driver requests IR polling, while dvb_usbv2_remote_exit() cancels that work whenever an rc device was registered. Drivers which register an rc device but decode IR in their own interrupt handler, such as lmedm04, never request polling, so the delayed work stays zeroed and disconnecting the device trips the flush_work() sanity check: WARNING: kernel/workqueue.c:4409 at __flush_work+0x8ed/0xaf0 ... cancel_delayed_work_sync dvb_usbv2_remote_exit dvb_usbv2_disconnect usb_unbind_interface ... Initialize the work item as soon as the rc device is registered, so that the exit path can keep cancelling it unconditionally. Cancelling an initialized but never queued work item is a no-op. Gating the cancellation on d->rc_polling_active would not work: the polling worker itself clears that flag when rc.query() fails, which is what happens while the device is being disconnected, so the exit path could skip waiting for a worker that is still running. Fixes: 05752890411c ("[media] dvb_usb_v2: remote controller changes") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> --- v2: - Initialize rc_query_work unconditionally instead of gating the cancellation on rc_polling_active: the polling worker clears that flag itself when rc.query() fails, so the exit path could skip waiting for a worker that is still running. drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index bd86d250433d..c97e6abd2d38 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -161,11 +161,14 @@ static int dvb_usbv2_remote_init(struct dvb_usb_device *d) d->rc_dev = dev; + /* + * Initialize the work item even for devices which do not use + * polling, so that it can always be cancelled on disconnect. + */ + INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control); + /* start polling if needed */ if (d->rc.query && !d->rc.bulk_mode) { - /* initialize a work queue for handling polling */ - INIT_DELAYED_WORK(&d->rc_query_work, - dvb_usb_read_remote_control); dev_info(&d->udev->dev, "%s: schedule remote query interval to %d msecs\n", KBUILD_MODNAME, d->rc.interval); -- 2.34.1