* [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()
@ 2020-02-13 19:40 Marcelo Diop-Gonzalez
2020-02-17 10:40 ` Dan Carpenter
2020-02-17 15:49 ` Nicolas Saenz Julienne
0 siblings, 2 replies; 5+ messages in thread
From: Marcelo Diop-Gonzalez @ 2020-02-13 19:40 UTC (permalink / raw)
To: nsaenzjulienne, gregkh; +Cc: devel, linux-rpi-kernel, dan.carpenter
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>
---
.../vc04_services/interface/vchiq_arm/vchiq_core.c | 14 +++++++++-----
1 file 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;
}
--
2.25.0.225.g125e21ebc7-goog
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()
2020-02-13 19:40 [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance() Marcelo Diop-Gonzalez
@ 2020-02-17 10:40 ` Dan Carpenter
2020-02-18 14:44 ` Marcelo Diop-Gonzalez
2020-02-17 15:49 ` Nicolas Saenz Julienne
1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2020-02-17 10:40 UTC (permalink / raw)
To: Marcelo Diop-Gonzalez; +Cc: devel, gregkh, linux-rpi-kernel
On Thu, Feb 13, 2020 at 02:40:01PM -0500, Marcelo Diop-Gonzalez wrote:
> 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>
> ---
Please use a Fixes tag.
Fixes: a2203cfe0d84 ("staging: vc04_services: don't increment service refcount when it's not needed")
That way we know it doesn't need to be backported.
regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()
2020-02-13 19:40 [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance() Marcelo Diop-Gonzalez
2020-02-17 10:40 ` Dan Carpenter
@ 2020-02-17 15:49 ` Nicolas Saenz Julienne
2020-02-18 14:45 ` Marcelo Diop-Gonzalez
1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Saenz Julienne @ 2020-02-17 15:49 UTC (permalink / raw)
To: Marcelo Diop-Gonzalez, gregkh; +Cc: devel, linux-rpi-kernel, dan.carpenter
On Thu Feb 13, 2020 at 2:40 PM, Marcelo Diop-Gonzalez wrote:
> 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>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Note that, as Dan says, picking up the Fixes tag would be nice.
> ---
> .../vc04_services/interface/vchiq_arm/vchiq_core.c | 14 +++++++++-----
> 1 file 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;
> }
> --
> 2.25.0.225.g125e21ebc7-goog
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()
2020-02-17 10:40 ` Dan Carpenter
@ 2020-02-18 14:44 ` Marcelo Diop-Gonzalez
0 siblings, 0 replies; 5+ messages in thread
From: Marcelo Diop-Gonzalez @ 2020-02-18 14:44 UTC (permalink / raw)
To: Dan Carpenter; +Cc: devel, Greg KH, linux-rpi-kernel
On Mon, Feb 17, 2020 at 5:40 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Thu, Feb 13, 2020 at 02:40:01PM -0500, Marcelo Diop-Gonzalez wrote:
> > 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>
> > ---
>
> Please use a Fixes tag.
>
> Fixes: a2203cfe0d84 ("staging: vc04_services: don't increment service refcount when it's not needed")
Ah yeah, forgot about that!
>
> That way we know it doesn't need to be backported.
>
> regards,
> dan carpenter
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()
2020-02-17 15:49 ` Nicolas Saenz Julienne
@ 2020-02-18 14:45 ` Marcelo Diop-Gonzalez
0 siblings, 0 replies; 5+ messages in thread
From: Marcelo Diop-Gonzalez @ 2020-02-18 14:45 UTC (permalink / raw)
To: Nicolas Saenz Julienne; +Cc: devel, Greg KH, linux-rpi-kernel, Dan Carpenter
On Mon, Feb 17, 2020 at 10:55 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> On Thu Feb 13, 2020 at 2:40 PM, Marcelo Diop-Gonzalez wrote:
> > 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>
>
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
thanks for reviewing!
>
> Note that, as Dan says, picking up the Fixes tag would be nice.
>
> > ---
> > .../vc04_services/interface/vchiq_arm/vchiq_core.c | 14 +++++++++-----
> > 1 file 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;
> > }
> > --
> > 2.25.0.225.g125e21ebc7-goog
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-02-18 14:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 19:40 [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance() Marcelo Diop-Gonzalez
2020-02-17 10:40 ` Dan Carpenter
2020-02-18 14:44 ` Marcelo Diop-Gonzalez
2020-02-17 15:49 ` Nicolas Saenz Julienne
2020-02-18 14:45 ` Marcelo Diop-Gonzalez
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.