Skip to contentSkip to conversation

media: as102: initialize mutexes before registering frontend

PATCH New Adriano Cordova 1 participant 1 message Sep 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 media: as102: initialize mutexes before registering frontend

The bus adapter mutex and the stream mutex are initialized after the frontend has been registered, but the frontend's stream control callback as102_stream_ctrl() takes the bus adapter mutex, which can be used before it is initialized:

	INFO: trying to register non-static key.
	...
	as102_stream_ctrl+0x27/0xc0 drivers/media/usb/as102/as102_drv.c:259
	dvb_frontend_open+0x7eb/0x1410 drivers/media/dvb-core/dvb_frontend.c:2825

Initialize the mutexes before registering the adapter and frontend.

Fixes 41b44e041811 ("[media] staging: as102: Initial import from Abilis")
Reported-by [email protected]

---
Changes since v1:
- Succesfully passed available repo. Added Tested-by tag.
Changes since v2:
- Reorder commit tags to fix warning.

 drivers/media/usb/as102/as102_drv.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/usb/as102/as102_drv.c +6 -6
index 6b1d3528a0a7..a6dd675689f5 100644
@@ -287,6 +287,12 @@ int as102_dvb_register(struct as102_dev_t *as102_dev)
 	struct device *dev = &as102_dev->bus_adap.usb_dev->dev;
 	int ret;
 
+	/* init bus mutex for token locking */
+	mutex_init(&as102_dev->bus_adap.lock);
+
+	/* init start / stop stream mutex */
+	mutex_init(&as102_dev->sem);
+
 	ret = dvb_register_adapter(&as102_dev->dvb_adap,
 			   as102_dev->name, THIS_MODULE,
 			   dev, adapter_nr);
@@ -341,12 +347,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.
Signature · 1 line
2.51.0