Commit e2327678 authored by Marcelo Diop-Gonzalez's avatar Marcelo Diop-Gonzalez Committed by Greg Kroah-Hartman

staging: vc04_services: Fix wrong early return in next_service_by_instance()

If kref_get_unless_zero() fails, we should keep looking for the
next service, since the callers of this function expect that a NULL
return value means there are no more.
Signed-off-by: default avatarMarcelo Diop-Gonzalez <marcgonzalez@google.com>
Link: https://lore.kernel.org/r/20200213194001.130110-1-marcgonzalez@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8ef0c4f0
...@@ -252,11 +252,15 @@ next_service_by_instance(struct vchiq_state *state, ...@@ -252,11 +252,15 @@ next_service_by_instance(struct vchiq_state *state,
struct vchiq_service *service; struct vchiq_service *service;
rcu_read_lock(); rcu_read_lock();
while (1) {
service = __next_service_by_instance(state, instance, pidx); service = __next_service_by_instance(state, instance, pidx);
if (service && kref_get_unless_zero(&service->ref_count)) if (!service)
break;
if (kref_get_unless_zero(&service->ref_count)) {
service = rcu_pointer_handoff(service); service = rcu_pointer_handoff(service);
else break;
service = NULL; }
}
rcu_read_unlock(); rcu_read_unlock();
return service; return service;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment