X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fidr.c;h=12499ba7967e08f5388835834c08c67dc7af5c24;hb=4c64616bb51b399886ded8f4f69bad4da2da1817;hp=ed055b297c81c127dcbef79cb821f904936245c2;hpb=09521577ca7718b6c83f095ca4f0d474b01a8378;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git diff --git a/lib/idr.c b/lib/idr.c index ed055b2..12499ba 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -595,8 +595,10 @@ EXPORT_SYMBOL(idr_for_each); * Returns pointer to registered object with id, which is next number to * given id. After being looked up, *@nextidp will be updated for the next * iteration. + * + * This function can be called under rcu_read_lock(), given that the leaf + * pointers lifetimes are correctly managed. */ - void *idr_get_next(struct idr *idp, int *nextidp) { struct idr_layer *p, *pa[MAX_LEVEL]; @@ -605,11 +607,11 @@ void *idr_get_next(struct idr *idp, int *nextidp) int n, max; /* find first ent */ - n = idp->layers * IDR_BITS; - max = 1 << n; p = rcu_dereference_raw(idp->top); if (!p) return NULL; + n = (p->layer + 1) * IDR_BITS; + max = 1 << n; while (id < max) { while (n > 0 && p) {