diff options
-rw-r--r-- | lib/idr.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -625,7 +625,14 @@ void *idr_get_next(struct idr *idp, int *nextidp) | |||
625 | return p; | 625 | return p; |
626 | } | 626 | } |
627 | 627 | ||
628 | id += 1 << n; | 628 | /* |
629 | * Proceed to the next layer at the current level. Unlike | ||
630 | * idr_for_each(), @id isn't guaranteed to be aligned to | ||
631 | * layer boundary at this point and adding 1 << n may | ||
632 | * incorrectly skip IDs. Make sure we jump to the | ||
633 | * beginning of the next layer using round_up(). | ||
634 | */ | ||
635 | id = round_up(id + 1, 1 << n); | ||
629 | while (n < fls(id)) { | 636 | while (n < fls(id)) { |
630 | n += IDR_BITS; | 637 | n += IDR_BITS; |
631 | p = *--paa; | 638 | p = *--paa; |