From patchwork Mon Sep 17 05:09:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1465001 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 6ECFC3FE79 for ; Mon, 17 Sep 2012 05:19:50 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TDTgL-00014f-OT; Mon, 17 Sep 2012 05:15:41 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TDTgH-00014R-7K for linux-arm-kernel@lists.infradead.org; Mon, 17 Sep 2012 05:15:39 +0000 Received: by pbbrq8 with SMTP id rq8so9260646pbb.36 for ; Sun, 16 Sep 2012 22:15:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=4ibz7xm6kKTUwEJQ+AoKpGqfxAs55YBMbfe+nfGDuMs=; b=f3oph7dOjQ0KS+lC0Vs8q7Ky0/rIoypXo0EdPaseCvDcJi/90YIkkm2eq5ytPCLoKU F30b9dL3Rre8sMhWy/B9mCPFdy+96rm+dWMX1uc7yGr7TANEp6MltmxwTdvNOgW3mXzC TgDcXgsrh7KPR5afufKsPkwMJgYQZbiz5zRa3dhhTRKooXekpltXNis1Krw8aBNfGC2v raYZjrFMcaokpl9R05GMLUtoWaxQ/LsLZEDIIOJ0gq4ObLYTEzEl/oPNI93OlB6d4QOh okzAXnBVrmyZLa874yxtzMRKS1/X+EpGd95vHxOgZc3n/GSHokKFaeDvVMwjObFw4RYC fClg== Received: by 10.68.193.194 with SMTP id hq2mr20504214pbc.93.1347858932132; Sun, 16 Sep 2012 22:15:32 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id gf8sm6343910pbc.52.2012.09.16.22.15.27 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 16 Sep 2012 22:15:31 -0700 (PDT) From: Sachin Kamat To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: dma-mapping: Fix potential memory leak in atomic_pool_init() Date: Mon, 17 Sep 2012 10:39:43 +0530 Message-Id: <1347858583-13338-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQk0JG7HqCj8KT2d4fJz1rZMPbibP4D5fqX7CG2ZwczC6mFLkzWg5eQ74UQyqH9ZzsdBw+F3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: sachin.kamat@linaro.org, Marek Szyprowski , linux-kernel@vger.kernel.org, Arnd Bergmann , patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When either of __alloc_from_contiguous or __alloc_remap_buffer fails to provide a valid pointer, allocated memory is freed up and an error is returned. 'pages' was however not freed before returning error. Cc: Arnd Bergmann Cc: Marek Szyprowski Signed-off-by: Sachin Kamat --- arch/arm/mm/dma-mapping.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 546a3e8..477a2d2 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -367,6 +367,8 @@ static int __init atomic_pool_init(void) (unsigned)pool->size / 1024); return 0; } + + kfree(pages); no_pages: kfree(bitmap); no_bitmap: