From patchwork Mon Dec 30 19:48:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Engelmayer X-Patchwork-Id: 3420641 X-Patchwork-Delegate: vinod.koul@intel.com Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A9D59F295 for ; Mon, 30 Dec 2013 19:48:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9CFC200F0 for ; Mon, 30 Dec 2013 19:48:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FC02200E9 for ; Mon, 30 Dec 2013 19:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932104Ab3L3Tsn (ORCPT ); Mon, 30 Dec 2013 14:48:43 -0500 Received: from mout.gmx.net ([212.227.15.19]:52252 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932094Ab3L3Tsn (ORCPT ); Mon, 30 Dec 2013 14:48:43 -0500 Received: from spike ([81.217.122.98]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0LjZn2-1VQZvt1FYO-00bZnk for ; Mon, 30 Dec 2013 20:48:41 +0100 Date: Mon, 30 Dec 2013 20:48:39 +0100 From: Christian Engelmayer To: Joel Fernandes Cc: Vinod Koul , dmaengine@vger.kernel.org Subject: [PATCH] dma: edma: Fix memory leak in edma_prep_dma_cyclic() Message-ID: <20131230204839.45aab6a7@spike> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.20; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Provags-ID: V03:K0:a5SmvOXjIO4JY5TUsh0ndR4+NhBP0dfk4FsMlTB/IIBXlz0iq0X I3DnZcfM0Z9/TlBKx9sh9TFE8Q1GUqKB+xiuxFEuFIqUe1RUY2Deescnj3oIRpkqWLhp8hq KqQaZaJ+grz4npehnd2qi2ngJ0zCIYxhguemX4AfeXG7l8EIgWP8YIj80L1HlwfE8zVXV3z WXjvu9+dhfEJ6j/DeFQsw== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix a memory leak in the edma_prep_dma_cyclic() error handling path. Signed-off-by: Christian Engelmayer --- This patch fixes an issue introduced in commit 50a9c70714dfb17a85a3fb762675a64f598d504b Author: Joel Fernandes Date: Thu Oct 31 16:31:23 2013 -0500 dma: edma: Add support for Cyclic DMA --- drivers/dma/edma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 2539ea0..420450e 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -539,6 +539,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic( edma_alloc_slot(EDMA_CTLR(echan->ch_num), EDMA_SLOT_ANY); if (echan->slot[i] < 0) { + kfree(edesc); dev_err(dev, "Failed to allocate slot\n"); return NULL; } @@ -553,8 +554,10 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic( ret = edma_config_pset(chan, &edesc->pset[i], src_addr, dst_addr, burst, dev_width, period_len, direction); - if (ret < 0) + if (ret < 0) { + kfree(edesc); return NULL; + } if (direction == DMA_DEV_TO_MEM) dst_addr += period_len;