diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/btree.c | 4 | ||||
-rw-r--r-- | lib/gcd.c | 3 | ||||
-rw-r--r-- | lib/genalloc.c | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/lib/btree.c b/lib/btree.c index 2a34392bcec..297124d4d8d 100644 --- a/lib/btree.c +++ b/lib/btree.c @@ -319,8 +319,8 @@ void *btree_get_prev(struct btree_head *head, struct btree_geo *geo, if (head->height == 0) return NULL; -retry: longcpy(key, __key, geo->keylen); +retry: dec_key(geo, key); node = head->node; @@ -351,7 +351,7 @@ retry: } miss: if (retry_key) { - __key = retry_key; + longcpy(key, retry_key, geo->keylen); retry_key = NULL; goto retry; } diff --git a/lib/gcd.c b/lib/gcd.c index f879033d982..433d89bd9d8 100644 --- a/lib/gcd.c +++ b/lib/gcd.c @@ -9,6 +9,9 @@ unsigned long gcd(unsigned long a, unsigned long b) if (a < b) swap(a, b); + + if (!b) + return a; while ((r = a % b) != 0) { a = b; b = r; diff --git a/lib/genalloc.c b/lib/genalloc.c index b41dd90f290..bb1d323845e 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -79,7 +79,9 @@ gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phys, size_t size, int nid) { struct gen_pool_chunk *chunk; - size_t nbytes; + int nbits = size >> pool->min_alloc_order; + int nbytes = sizeof(struct gen_pool_chunk) + + BITS_TO_LONGS(nbits) * sizeof(long); if (WARN_ON(!virt || virt + size < virt || (virt & ((1 << pool->order) - 1)))) |