diff options
author | Lajos Molnar <molnar@ti.com> | 2011-04-07 08:41:53 +0100 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2011-04-07 08:41:53 +0100 |
commit | 9397b88e8f5bf23ae7c1ef1fe7513bdd4b22d663 (patch) | |
tree | 3d4d784dc505b64f02cf8f338031d03f7413f4e1 /drivers/media/video/tiler | |
parent | 8ed23789178b1fd74bbd1788873a341945cd4974 (diff) |
TILER: Correct PAT array allocation error handling
Avoid memory leaks if PAT array allocation fails, or if further
initializations fail.
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Signed-off-by: David Sin <davidsin@ti.com>
Signed-off-by: Lajos Molnar <molnar@ti.com>
Signed-off-by: David Sin <davidsin@ti.com>
Diffstat (limited to 'drivers/media/video/tiler')
-rw-r--r-- | drivers/media/video/tiler/tiler-main.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/media/video/tiler/tiler-main.c b/drivers/media/video/tiler/tiler-main.c index df5ebfaf681..c755567edd5 100644 --- a/drivers/media/video/tiler/tiler-main.c +++ b/drivers/media/video/tiler/tiler-main.c @@ -1125,6 +1125,15 @@ static s32 __init tiler_init(void) granularity & (granularity - 1)) return -EINVAL; + /* + * 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; @@ -1142,15 +1151,6 @@ static s32 __init tiler_init(void) tmm[TILFMT_32BIT] = tmm_pat; tmm[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.nv12_packed = tcm[TILFMT_8BIT] == tcm[TILFMT_16BIT]; tiler_device = kmalloc(sizeof(*tiler_device), GFP_KERNEL); @@ -1200,6 +1200,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; |