Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: iio: Fix incorrect existence check for a shared event pointer.

A second smatch detected error. First part fixes in a typo
in the comment directly above that I noticed whilst trying
to remember what this code actually does. Second part is
the actual fix. I'm fairly amazed this one never caused
trouble in testing as it is in one of the most common paths.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Jonathan Cameron and committed by
Greg Kroah-Hartman
75b16013 75c80753

+8 -8
+8 -8
drivers/staging/iio/industrialio-core.c
··· 292 292 mutex_unlock(&ev_int->event_list_lock); 293 293 /* 294 294 * Possible concurency issue if an update of this event is on its way 295 - * through. May lead to new even being removed whilst the reported event 296 - * was the unescalated event. In typical use case this is not a problem 297 - * as userspace will say read half the buffer due to a 50% full event 298 - * which would make the correct 100% full incorrect anyway. 295 + * through. May lead to new event being removed whilst the reported 296 + * event was the unescalated event. In typical use case this is not a 297 + * problem as userspace will say read half the buffer due to a 50% 298 + * full event which would make the correct 100% full incorrect anyway. 299 299 */ 300 - spin_lock(&el->shared_pointer->lock); 301 - if (el->shared_pointer) 300 + if (el->shared_pointer) { 301 + spin_lock(&el->shared_pointer->lock); 302 302 (el->shared_pointer->ev_p) = NULL; 303 - spin_unlock(&el->shared_pointer->lock); 304 - 303 + spin_unlock(&el->shared_pointer->lock); 304 + } 305 305 kfree(el); 306 306 307 307 return len;