[media] v4l: async: Make it safe to unregister unregistered notifier
[firefly-linux-kernel-4.4.55.git] / drivers / media / v4l2-core / v4l2-async.c
index b350ab99652ce58131b8d8b8505c61d5accce9c6..10bb62cb8d7d2c886731aa82bd0c0a39554a9c2e 100644 (file)
@@ -192,6 +192,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
        struct device *dev[n_subdev];
        int i = 0;
 
+       if (!notifier->v4l2_dev)
+               return;
+
        mutex_lock(&list_lock);
 
        list_del(&notifier->list);
@@ -225,6 +228,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
                }
                put_device(d);
        }
+
+       notifier->v4l2_dev = NULL;
+
        /*
         * Don't care about the waiting list, it is initialised and populated
         * upon notifier registration.