summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Diop-Gonzalez <marcgonzalez@google.com>2020-02-13 14:40:01 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-13 11:51:14 -0800
commite2327678732d78c90dec024e0ba4c9b65ca9cdd2 (patch)
tree29e4e0ec92af5a8a9ca452f26891ead1f0e76962
parent8ef0c4f06432b5b2f4e32f37b81708eae1e20c8c (diff)
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: Marcelo Diop-Gonzalez <marcgonzalez@google.com> Link: https://lore.kernel.org/r/20200213194001.130110-1-marcgonzalez@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index d7d7f4d9d57f..edcd97373809 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -252,11 +252,15 @@ next_service_by_instance(struct vchiq_state *state,
struct vchiq_service *service;
rcu_read_lock();
- service = __next_service_by_instance(state, instance, pidx);
- if (service && kref_get_unless_zero(&service->ref_count))
- service = rcu_pointer_handoff(service);
- else
- service = NULL;
+ while (1) {
+ service = __next_service_by_instance(state, instance, pidx);
+ if (!service)
+ break;
+ if (kref_get_unless_zero(&service->ref_count)) {
+ service = rcu_pointer_handoff(service);
+ break;
+ }
+ }
rcu_read_unlock();
return service;
}