if (map->crush)
crush_destroy(map->crush);
kfree(map->osd_state);
+ kfree(map->osd_addr);
kfree(map);
}
__u8 *state;
struct ceph_entity_addr *addr;
- state = kzalloc(max * (sizeof(__u32) +
- sizeof(struct ceph_entity_addr)),
- GFP_NOFS);
- if (state == NULL)
+ state = kzalloc(max * sizeof(__u32), GFP_NOFS);
+ addr = kzalloc(max * sizeof(struct ceph_entity_addr), GFP_NOFS);
+ if (state == NULL || addr == NULL) {
+ kfree(state);
+ kfree(addr);
return -ENOMEM;
- addr = (void *)((__u32 *)state + max);
+ }
/* copy old? */
if (map->osd_state) {
- memcpy(state, map->osd_state, map->max_osd);
- memcpy(addr, map->osd_addr, map->max_osd);
+ memcpy(state, map->osd_state, map->max_osd*sizeof(*state));
+ memcpy(addr, map->osd_addr, map->max_osd*sizeof(*addr));
kfree(map->osd_state);
+ kfree(map->osd_addr);
}
map->osd_state = state;