Re: [PATCH 3/3] drivers: net: davinci_cpdma: Convert kzalloc() to devm_kzalloc().
From: Felipe Balbi
Date: Fri May 02 2014 - 10:21:32 EST
Hi,
On Fri, May 02, 2014 at 03:50:17PM +0530, George Cherian wrote:
> Convert kzalloc() to devm_kzalloc().
>
> Signed-off-by: George Cherian <george.cherian@xxxxxx>
> ---
> drivers/net/ethernet/ti/davinci_cpdma.c | 32 ++++++++++++--------------------
> 1 file changed, 12 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> index 88ef270..b83ffbb 100644
> --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> @@ -158,9 +158,9 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
> int bitmap_size;
> struct cpdma_desc_pool *pool;
>
> - pool = kzalloc(sizeof(*pool), GFP_KERNEL);
> + pool = devm_kzalloc(dev, sizeof(*pool), GFP_KERNEL);
> if (!pool)
> - return NULL;
> + goto fail;
>
> spin_lock_init(&pool->lock);
>
> @@ -170,7 +170,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
> pool->num_desc = size / pool->desc_size;
>
> bitmap_size = (pool->num_desc / BITS_PER_LONG) * sizeof(long);
> - pool->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
> + pool->bitmap = devm_kzalloc(dev, bitmap_size, GFP_KERNEL);
> if (!pool->bitmap)
> goto fail;
>
> @@ -187,10 +187,7 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
>
> if (pool->iomap)
> return pool;
> -
> fail:
> - kfree(pool->bitmap);
> - kfree(pool);
remove kfree() on cpda_desc_pool_destroy() too.
> return NULL;
> }
>
> @@ -276,7 +273,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
> {
> struct cpdma_ctlr *ctlr;
>
> - ctlr = kzalloc(sizeof(*ctlr), GFP_KERNEL);
> + ctlr = devm_kzalloc(params->dev, sizeof(*ctlr), GFP_KERNEL);
likewise, drop the kfree() in cpdma_ctlr_destroy()
Fix those and you can add
Reviewed-by: Felipe Balbi <balbi@xxxxxx>
--
balbi
Attachment:
signature.asc
Description: Digital signature