From patchwork Wed Jul 14 16:01:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sin, David" X-Patchwork-Id: 58972 X-Patchwork-Delegate: tim.gardner@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 8ECADB6F11 for ; Thu, 15 Jul 2010 21:56:21 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OZN2x-0002oD-5J; Thu, 15 Jul 2010 12:56:11 +0100 Received: from comal.ext.ti.com ([198.47.26.152]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1OZ4OT-00004w-Im for kernel-team@lists.ubuntu.com; Wed, 14 Jul 2010 17:01:09 +0100 Received: from dlep36.itg.ti.com ([157.170.170.91]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o6EG172a013887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 Jul 2010 11:01:07 -0500 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o6EG177k005294; Wed, 14 Jul 2010 11:01:07 -0500 (CDT) Received: from dlee74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o6EG17nh006353; Wed, 14 Jul 2010 11:01:07 -0500 (CDT) Received: from dlee02.ent.ti.com ([157.170.170.17]) by dlee74.ent.ti.com ([157.170.170.8]) with mapi; Wed, 14 Jul 2010 11:01:07 -0500 From: "Sin, David" To: Bryan Wu , "kernel-team@lists.ubuntu.com" Date: Wed, 14 Jul 2010 11:01:06 -0500 Subject: [PATCH] TILER: Corrrect PAT array allocation error handling Thread-Topic: [PATCH] TILER: Corrrect PAT array allocation error handling Thread-Index: AcsjbcR8WE9vJkveTg2FYEK2IBWUlg== Message-ID: <513FF747EED39B4AADBB4D6C9D9F9F7903D6103FCE@dlee02.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 15 Jul 2010 12:56:09 +0100 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com 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 Date: Wed, 14 Jul 2010 10:47:07 -0500 Subject: [PATCH] TILER: Corrrect PAT array allocation error handling Signed-off-by: Bryan Wu Signed-off-by: David Sin --- 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;