Message ID | 51818AB2.1060909@inktank.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Reviewed-by: Josh Durgin <josh.durgin@inktank.com> On 05/01/2013 02:35 PM, Alex Elder wrote: > 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> > --- > drivers/block/rbd.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index 005c397..da9f41d 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); > } > -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 005c397..da9f41d 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;
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> --- drivers/block/rbd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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); }