diff options
Diffstat (limited to 'fs/ceph/osdmap.c')
-rw-r--r-- | fs/ceph/osdmap.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c index 8c8ffe5ef7d4..a9416308de6f 100644 --- a/fs/ceph/osdmap.c +++ b/fs/ceph/osdmap.c | |||
@@ -200,6 +200,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
200 | size = sizeof(struct crush_bucket_straw); | 200 | size = sizeof(struct crush_bucket_straw); |
201 | break; | 201 | break; |
202 | default: | 202 | default: |
203 | err = -EINVAL; | ||
203 | goto bad; | 204 | goto bad; |
204 | } | 205 | } |
205 | BUG_ON(size == 0); | 206 | BUG_ON(size == 0); |
@@ -278,6 +279,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
278 | /* len */ | 279 | /* len */ |
279 | ceph_decode_32_safe(p, end, yes, bad); | 280 | ceph_decode_32_safe(p, end, yes, bad); |
280 | #if BITS_PER_LONG == 32 | 281 | #if BITS_PER_LONG == 32 |
282 | err = -EINVAL; | ||
281 | if (yes > ULONG_MAX / sizeof(struct crush_rule_step)) | 283 | if (yes > ULONG_MAX / sizeof(struct crush_rule_step)) |
282 | goto bad; | 284 | goto bad; |
283 | #endif | 285 | #endif |
@@ -489,11 +491,10 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) | |||
489 | ceph_decode_copy(p, &pgid, sizeof(pgid)); | 491 | ceph_decode_copy(p, &pgid, sizeof(pgid)); |
490 | n = ceph_decode_32(p); | 492 | n = ceph_decode_32(p); |
491 | ceph_decode_need(p, end, n * sizeof(u32), bad); | 493 | ceph_decode_need(p, end, n * sizeof(u32), bad); |
494 | err = -ENOMEM; | ||
492 | pg = kmalloc(sizeof(*pg) + n*sizeof(u32), GFP_NOFS); | 495 | pg = kmalloc(sizeof(*pg) + n*sizeof(u32), GFP_NOFS); |
493 | if (!pg) { | 496 | if (!pg) |
494 | err = -ENOMEM; | ||
495 | goto bad; | 497 | goto bad; |
496 | } | ||
497 | pg->pgid = pgid; | 498 | pg->pgid = pgid; |
498 | pg->len = n; | 499 | pg->len = n; |
499 | for (j = 0; j < n; j++) | 500 | for (j = 0; j < n; j++) |
@@ -564,8 +565,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
564 | if (len > 0) { | 565 | if (len > 0) { |
565 | dout("apply_incremental full map len %d, %p to %p\n", | 566 | dout("apply_incremental full map len %d, %p to %p\n", |
566 | len, *p, end); | 567 | len, *p, end); |
567 | newmap = osdmap_decode(p, min(*p+len, end)); | 568 | return osdmap_decode(p, min(*p+len, end)); |
568 | return newmap; /* error or not */ | ||
569 | } | 569 | } |
570 | 570 | ||
571 | /* new crush? */ | 571 | /* new crush? */ |
@@ -809,6 +809,7 @@ int ceph_calc_object_layout(struct ceph_object_layout *ol, | |||
809 | struct ceph_pg_pool_info *pool; | 809 | struct ceph_pg_pool_info *pool; |
810 | unsigned ps; | 810 | unsigned ps; |
811 | 811 | ||
812 | BUG_ON(!osdmap); | ||
812 | if (poolid >= osdmap->num_pools) | 813 | if (poolid >= osdmap->num_pools) |
813 | return -EIO; | 814 | return -EIO; |
814 | 815 | ||