]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] coverity: idr_get_new_above_int() overrun fix
authorZaur Kambarov <kambarov@berkeley.edu>
Wed, 22 Jun 2005 00:14:31 +0000 (17:14 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 22 Jun 2005 01:46:12 +0000 (18:46 -0700)
This patch fixes overrun of array pa:
92    struct idr_layer *pa[MAX_LEVEL];

in

98    l = idp->layers;
99    pa[l--] = NULL;

by passing idp->layers, set in
202   idp->layers = layers;
to function  sub_alloc in
203   v = sub_alloc(idp, ptr, &id);

Signed-off-by: Zaur Kambarov <zkambarov@coverity.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
lib/idr.c

index 81fc430602ee8f4c2b4e336a606813ad54b0e5b2..c5be889de449555dc31b5c5d50a061f34187fdb6 100644 (file)
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -175,7 +175,7 @@ build_up:
         * Add a new layer to the top of the tree if the requested
         * id is larger than the currently allocated space.
         */
-       while ((layers < MAX_LEVEL) && (id >= (1 << (layers*IDR_BITS)))) {
+       while ((layers < (MAX_LEVEL - 1)) && (id >= (1 << (layers*IDR_BITS)))) {
                layers++;
                if (!p->count)
                        continue;