Skip to contentSkip to conversation

uvc: fix access to uninitialized fields on probe error

PATCH In review Oliver Neukum 2 participants 3 messages Apr 30, 2019 – May 6, 2019

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

PATCH 1/1 uvc: fix access to uninitialized fields on probe error

We need to check whether this work we are canceling actually is initialized.

---
 drivers/media/usb/uvc/uvc_ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_ctrl.c +3 -1
index 14cff91b7aea..2b510c56cf91 100644
@@ -2350,7 +2350,9 @@ void uvc_ctrl_cleanup_device(struct uvc_device *dev)
 	struct uvc_entity *entity;
 	unsigned int i;
 
-	cancel_work_sync(&dev->async_ctrl.work);
+	/* can be uninitialized if we are aborting on probe error */
+	if (dev->async_ctrl.work.func)
+		cancel_work_sync(&dev->async_ctrl.work);
 
 	/* Free controls and control mappings for all entities. */
 	list_for_each_entry(entity, &dev->entities, list) {
Signature · 1 line
2.16.4
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Oliver,

Thank you for the patch.

Quoted 2 lines · Oliver Neukum

We need to check whether this work we are canceling actually is initialized.

I think we should add

Fixes e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives")
Quoted 11 lines
---
 drivers/media/usb/uvc/uvc_ctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_ctrl.c +0 -0
index 14cff91b7aea..2b510c56cf91 100644

drivers/media/usb/uvc/uvc_ctrl.c void uvc_ctrl_cleanup_device(struct uvc_device *dev) · line 2353

Quoted 5 lines
drivers/media/usb/uvc/uvc_ctrl.c +1 -1
@@ -2350,7 +2350,9 @@ void uvc_ctrl_cleanup_device(struct uvc_device *dev)
 	struct uvc_entity *entity;
 	unsigned int i;
 
-	cancel_work_sync(&dev->async_ctrl.work);
+	/* can be uninitialized if we are aborting on probe error */

Let's capitalise the comment and end it with a period to match the rest of the driver. With these small issues fixed,

If you agree with the changes there's no need to resubmit, I'll fix when applying.

Quoted 5 lines
drivers/media/usb/uvc/uvc_ctrl.c +2 -0
+	if (dev->async_ctrl.work.func)
+		cancel_work_sync(&dev->async_ctrl.work);
 
 	/* Free controls and control mappings for all entities. */
 	list_for_each_entry(entity, &dev->entities, list) {
Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
Quoted 4 lines · Laurent Pinchart

Let's capitalise the comment and end it with a period to match the rest of the driver. With these small issues fixed,

Hi,

thank you. I agree with them.

Regards
Oliver