Re: [PATCH] staging: vc04_services: Fix wrong early return in next_service_by_instance()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 17, 2020 at 10:55 AM Nicolas Saenz Julienne
<nsaenzjulienne@xxxxxxx> 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@xxxxxxxxxx>
>
> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@xxxxxxx>
> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@xxxxxxx>

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@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux