staging: iio: Fix incorrect existence check for a shared event pointer.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / iio / industrialio-core.c
index 87799b2a9262e5fbdc1803542b25ead96642211f..4ff683a3df316e073044ad38b8d36d0f4b269f4c 100644 (file)
@@ -292,16 +292,16 @@ ssize_t iio_event_chrdev_read(struct file *filep,
        mutex_unlock(&ev_int->event_list_lock);
        /*
         * Possible concurency issue if an update of this event is on its way
-        * through. May lead to new even being removed whilst the reported event
-        * was the unescalated event. In typical use case this is not a problem
-        * as userspace will say read half the buffer due to a 50% full event
-        * which would make the correct 100% full incorrect anyway.
+        * through. May lead to new event being removed whilst the reported
+        * event was the unescalated event. In typical use case this is not a
+        * problem as userspace will say read half the buffer due to a 50%
+        * full event which would make the correct 100% full incorrect anyway.
         */
-       spin_lock(&el->shared_pointer->lock);
-       if (el->shared_pointer)
+       if (el->shared_pointer) {
+               spin_lock(&el->shared_pointer->lock);
                (el->shared_pointer->ev_p) = NULL;
-       spin_unlock(&el->shared_pointer->lock);
-
+               spin_unlock(&el->shared_pointer->lock);
+       }
        kfree(el);
 
        return len;