On 12/20/25 23:27, Sean Young wrote:
> rc_unregister_device() does two things: it marks the device as
> unregistered, so no new commands can be issued via the lirc chardev,
> and also frees the rc device. Device drivers want to both cancel
> in-flight commands (i.e. kill urbs) and prevent further commands from
> being issued. Only once both are done, can we really free the rc device,
> because it might be referenced in urb callbacks. This is impossible to
> do with the current way of things.
>
> 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]/
> Signed-off-by: Sean Young <[email protected]>
> ---
> drivers/gpu/drm/bridge/sil-sii8620.c | 1 +
> drivers/hid/hid-picolcd_cir.c | 1 +
> drivers/media/cec/core/cec-core.c | 2 +-
> drivers/media/common/siano/smsir.c | 1 +
> drivers/media/i2c/ir-kbd-i2c.c | 2 ++
> drivers/media/pci/bt8xx/bttv-input.c | 1 +
> drivers/media/pci/cx23885/cx23885-input.c | 1 +
> drivers/media/pci/cx88/cx88-input.c | 1 +
> drivers/media/pci/dm1105/dm1105.c | 1 +
> drivers/media/pci/mantis/mantis_input.c | 1 +
> drivers/media/pci/saa7134/saa7134-input.c | 1 +
> drivers/media/pci/smipcie/smipcie-ir.c | 1 +
> drivers/media/pci/ttpci/budget-ci.c | 1 +
> drivers/media/rc/ati_remote.c | 4 ++--
> drivers/media/rc/ene_ir.c | 2 +-
> drivers/media/rc/fintek-cir.c | 3 ++-
> drivers/media/rc/igorplugusb.c | 1 +
> drivers/media/rc/iguanair.c | 1 +
> drivers/media/rc/img-ir/img-ir-hw.c | 3 ++-
> drivers/media/rc/img-ir/img-ir-raw.c | 3 ++-
> drivers/media/rc/imon.c | 3 ++-
> drivers/media/rc/ir-hix5hd2.c | 2 +-
> drivers/media/rc/ir_toy.c | 1 +
> drivers/media/rc/ite-cir.c | 2 +-
> drivers/media/rc/mceusb.c | 1 +
> drivers/media/rc/rc-ir-raw.c | 5 -----
> drivers/media/rc/rc-loopback.c | 1 +
> drivers/media/rc/rc-main.c | 6 +-----
> drivers/media/rc/redrat3.c | 4 +++-
> drivers/media/rc/st_rc.c | 2 +-
> drivers/media/rc/streamzap.c | 3 ++-
> drivers/media/rc/sunxi-cir.c | 1 +
> drivers/media/rc/ttusbir.c | 2 +-
> drivers/media/rc/winbond-cir.c | 2 +-
> drivers/media/rc/xbox_remote.c | 3 ++-
> drivers/media/usb/au0828/au0828-input.c | 1 +
> drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 1 +
> drivers/media/usb/dvb-usb/dvb-usb-remote.c | 6 ++++--
> drivers/media/usb/em28xx/em28xx-input.c | 1 +
> drivers/staging/media/av7110/av7110_ir.c | 1 +
> include/media/rc-core.h | 2 --
> 41 files changed, 52 insertions(+), 30 deletions(-)
>
[...]
> diff --git a/drivers/media/rc/st_rc.c b/drivers/media/rc/st_rc.c
> index 6b70bac5f45d6..0ba06bfc9e14b 100644
> --- a/drivers/media/rc/st_rc.c
> +++ b/drivers/media/rc/st_rc.c
> @@ -203,6 +203,7 @@ static void st_rc_remove(struct platform_device *pdev)
> device_init_wakeup(&pdev->dev, false);
> clk_disable_unprepare(rc_dev->sys_clock);
> rc_unregister_device(rc_dev->rdev);
> + rc_free_device(rc_dev->rdev);
> }
>
> static int st_rc_open(struct rc_dev *rdev)
> @@ -334,7 +335,6 @@ static int st_rc_probe(struct platform_device *pdev)
> return ret;
> rcerr:
> rc_unregister_device(rdev);
> - rdev = NULL;
> clkerr:
> clk_disable_unprepare(rc_dev->sys_clock);
> err:
> diff --git a/drivers/media/rc/streamzap.c b/drivers/media/rc/streamzap.c
> index d3b48a0dd1f47..b9b241fe46ea1 100644
Reviewed-by: Patrice Chotard <[email protected]>
Thanks
Patrice