MLK-11508-2 v4l2: Add v4l2_async_notifier_unregister recursively call
authorSandor Yu <R01008@freescale.com>
Fri, 29 May 2015 09:07:04 +0000 (17:07 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:38 +0000 (14:48 -0500)
If anyone calls v4l2_async_notifier_unregister() recursively from
device_release_driver(), code will deadlock at list_lock, so unlock
list_lock when device_release_driver() called.

Signed-off-by: Sandor Yu <R01008@freescale.com>
(cherry picked from commit f0b54df4d1b58f8f6608e1b08a80a5acb8cc12ea)

drivers/media/v4l2-core/v4l2-async.c

index 5bada20..76996b5 100644 (file)
@@ -220,7 +220,14 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
                v4l2_async_cleanup(sd);
 
                /* If we handled USB devices, we'd have to lock the parent too */
+               /*
+                * If anyone calls v4l2_async_notifier_unregister() recursively from
+                * device_release_driver(), code will deadlock at list_lock,
+                * so unlock list_lock when device_release_driver() called.
+                */
+               mutex_unlock(&list_lock);
                device_release_driver(d);
+               mutex_lock(&list_lock);
 
                if (notifier->unbind)
                        notifier->unbind(notifier, sd, sd->asd);