[PATCH] media: usb: as102: Initialize callback locks before DVB registration
From: Runyu Xiao
Date: Tue Sep 29 2026 - 06:56:10 EST
The AS102 DVB frontend and demux callbacks use bus_adap.lock and sem. DVB
registration publishes the frontend and demux devices before either lock is
initialized, allowing a userspace callback to run before the lock is ready.
Initialize the callback state before registering the adapter.
Fixes: 41b44e041811 ("[media] staging: as102: Initial import from Abilis")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
---
drivers/media/usb/as102/as102_drv.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/media/usb/as102/as102_drv.c b/drivers/media/usb/as102/as102_drv.c
index 6b1d3528a..f3e2acf8f 100644
--- a/drivers/media/usb/as102/as102_drv.c
+++ b/drivers/media/usb/as102/as102_drv.c
@@ -287,6 +287,10 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
struct device *dev = &as102_dev->bus_adap.usb_dev->dev;
int ret;
+ /* Initialize callback state before registering the DVB adapter. */
+ mutex_init(&as102_dev->bus_adap.lock);
+ mutex_init(&as102_dev->sem);
+
ret = dvb_register_adapter(&as102_dev->dvb_adap,
as102_dev->name, THIS_MODULE,
dev, adapter_nr);
@@ -341,12 +345,6 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
goto efereg;
}
- /* init bus mutex for token locking */
- mutex_init(&as102_dev->bus_adap.lock);
-
- /* init start / stop stream mutex */
- mutex_init(&as102_dev->sem);
-
/*
* try to load as102 firmware. If firmware upload failed, we'll be
* able to upload it later.
--
2.34.1