summaryrefslogtreecommitdiff
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-05-01 17:43:03 (GMT)
committerAlex Elder <elder@inktank.com>2013-05-02 16:58:29 (GMT)
commitf907ad55967fec6bc6ec5ee84021070c49cf0bb1 (patch)
tree1b153aa4ba83f9ecaf890e2cc90204aafd6c2d29 /drivers/block/rbd.c
parent1c2a9dfe2107e81b9f0ee90845c687cf7ff84106 (diff)
downloadlinux-f907ad55967fec6bc6ec5ee84021070c49cf0bb1.tar.xz
rbd: allocate name separate from obj_request
The next patch will define a slab allocator for a object requests. To use that we'll need to allocate the name of an object separate from the request structure itself. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e90abde..d74be04 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1758,11 +1758,16 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name,
rbd_assert(obj_request_type_valid(type));
size = strlen(object_name) + 1;
- obj_request = kzalloc(sizeof (*obj_request) + size, GFP_KERNEL);
- if (!obj_request)
+ name = kmalloc(size, GFP_KERNEL);
+ if (!name)
+ return NULL;
+
+ obj_request = kzalloc(sizeof (*obj_request), GFP_KERNEL);
+ if (!obj_request) {
+ kfree(name);
return NULL;
+ }
- name = (char *)(obj_request + 1);
obj_request->object_name = memcpy(name, object_name, size);
obj_request->offset = offset;
obj_request->length = length;
@@ -1808,6 +1813,7 @@ static void rbd_obj_request_destroy(struct kref *kref)
break;
}
+ kfree(obj_request->object_name);
kfree(obj_request);
}