The call to v4l2_async_cleanup() will set sd->asd to NULL so passing it
to notifier->unbind() have no effect and leaves the notifier confused.
Call the unbind() callback prior to cleaning up the subdevice to avoid
this.

Signed-off-by: Niklas Söderlund <[email protected]>
---
 drivers/media/v4l2-core/v4l2-async.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c 
b/drivers/media/v4l2-core/v4l2-async.c
index 851f128eba2219ad..0acf288d7227ba97 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -226,14 +226,14 @@ void v4l2_async_notifier_unregister(struct 
v4l2_async_notifier *notifier)
 
                d = get_device(sd->dev);
 
+               if (notifier->unbind)
+                       notifier->unbind(notifier, sd, sd->asd);
+
                v4l2_async_cleanup(sd);
 
                /* If we handled USB devices, we'd have to lock the parent too 
*/
                device_release_driver(d);
 
-               if (notifier->unbind)
-                       notifier->unbind(notifier, sd, sd->asd);
-
                /*
                 * Store device at the device cache, in order to call
                 * put_device() on the final step
-- 
2.13.1

Reply via email to