[PATCH] TILER: Corrrect PAT array allocation error handling

Bryan Wu bryan.wu at canonical.com
Thu Jul 15 02:57:51 UTC 2010


David,

Thanks for updating promptly. I'd like to fold this patch into your original one
and send them out for review and merge.

I saw you've sent out this email to our mail list, did you subscribe to our mail
list? I failed to found this email in our mail list archive.

BTW, I can't apply this patch on top of your original one cleanly within our
Ubuntu Maverick kernel tree. But I fixed that.

Best Regards,
-Bryan

On 07/15/2010 12:01 AM, Sin, David wrote:
> Bryan,
> Can you please review this patch?  This patch fixes resource leaks if dma_alloc_coherent fails during TILER init.
> 
> Thanks for your input.
> 
> -David
> 
> 
> From ba6db483a22314f1e5fd7227158213ca9eaa94e9 Mon Sep 17 00:00:00 2001
> From: David Sin <davidsin at ti.com>
> Date: Wed, 14 Jul 2010 10:47:07 -0500
> Subject: [PATCH] TILER: Corrrect PAT array allocation error handling
> 
> Signed-off-by: Bryan Wu <bryan.wu at canonical.com>
> Signed-off-by: David Sin <davidsin at ti.com>
> ---
>  drivers/media/video/tiler/tiler.c |   20 +++++++++++---------
>  1 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/video/tiler/tiler.c b/drivers/media/video/tiler/tiler.c
> index 3b6cef3..2b8292d 100644
> --- a/drivers/media/video/tiler/tiler.c
> +++ b/drivers/media/video/tiler/tiler.c
> @@ -1486,6 +1486,15 @@ static s32 __init tiler_init(void)
>  	struct tcm *sita = NULL;
>  	struct tmm *tmm_pat = NULL;
>  
> +	/**
> +	  * Array of physical pages for PAT programming, which must be a 16-byte
> +	  * aligned physical address
> +	*/
> +	dmac_va = dma_alloc_coherent(NULL, TILER_WIDTH * TILER_HEIGHT *
> +					sizeof(*dmac_va), &dmac_pa, GFP_ATOMIC);
> +	if (!dmac_va)
> +		return -ENOMEM;
> +
>  	/* Allocate tiler container manager (we share 1 on OMAP4) */
>  	div_pt.x = TILER_WIDTH;   /* hardcoded default */
>  	div_pt.y = (3 * TILER_HEIGHT) / 4;
> @@ -1503,15 +1512,6 @@ static s32 __init tiler_init(void)
>  	TMM_SET(TILFMT_32BIT, tmm_pat);
>  	TMM_SET(TILFMT_PAGE, tmm_pat);
>  
> -	/**
> -	  * Array of physical pages for PAT programming, which must be a 16-byte
> -	  * aligned physical address
> -	*/
> -	dmac_va = dma_alloc_coherent(NULL, TILER_WIDTH * TILER_HEIGHT *
> -					sizeof(*dmac_va), &dmac_pa, GFP_ATOMIC);
> -	if (!dmac_va)
> -		return -ENOMEM;
> -
>  	tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL);
>  	if (!tiler_device || !sita || !tmm_pat) {
>  		r = -ENOMEM;
> @@ -1561,6 +1561,8 @@ error:
>  		kfree(tiler_device);
>  		tcm_deinit(sita);
>  		tmm_deinit(tmm_pat);
> +		dma_free_coherent(NULL, TILER_WIDTH * TILER_HEIGHT *
> +					sizeof(*dmac_va), dmac_va, dmac_pa);
>  	}
>  
>  	return r;




More information about the kernel-team mailing list