From patchwork Mon Aug 29 11:33:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Per Forlin X-Patchwork-Id: 3764 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CA61723F41 for ; Mon, 29 Aug 2011 11:34:18 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id BF801A18045 for ; Mon, 29 Aug 2011 11:34:18 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 18so6401918fxd.11 for ; Mon, 29 Aug 2011 04:34:18 -0700 (PDT) Received: by 10.223.62.8 with SMTP id v8mr3269246fah.43.1314617658513; Mon, 29 Aug 2011 04:34:18 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs93065lab; Mon, 29 Aug 2011 04:34:18 -0700 (PDT) Received: by 10.204.132.212 with SMTP id c20mr2057011bkt.352.1314617658045; Mon, 29 Aug 2011 04:34:18 -0700 (PDT) Received: from mail-bw0-f50.google.com (mail-bw0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id l2si2665761bke.162.2011.08.29.04.34.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Aug 2011 04:34:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) smtp.mail=per.forlin@linaro.org Received: by mail-bw0-f50.google.com with SMTP id zu5so5471497bkb.37 for ; Mon, 29 Aug 2011 04:34:16 -0700 (PDT) Received: by 10.204.130.130 with SMTP id t2mr2066352bks.223.1314617656749; Mon, 29 Aug 2011 04:34:16 -0700 (PDT) Received: from localhost.localdomain (c-c37f71d5.029-82-6c756e10.cust.bredbandsbolaget.se [213.113.127.195]) by mx.google.com with ESMTPS id s10sm1185215bka.64.2011.08.29.04.34.15 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Aug 2011 04:34:15 -0700 (PDT) From: Per Forlin To: linux-kernel@vger.kernel.org, Linus Walleij , Rabin Vincent Cc: Vinod Koul , linaro-dev@lists.linaro.org, Per Forlin Subject: [PATCH 4/4] dmaengine/ste_dma40: fix memory leak due to prepared descriptors Date: Mon, 29 Aug 2011 13:33:35 +0200 Message-Id: <1314617615-2394-5-git-send-email-per.forlin@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314617615-2394-1-git-send-email-per.forlin@linaro.org> References: <1314617615-2394-1-git-send-email-per.forlin@linaro.org> Prepared descriptors that are not submitted will not be freed. Add prepared descriptor to a list to be able to release them upon dmaengine_terminate_all(). Signed-off-by: Per Forlin --- drivers/dma/ste_dma40.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 92ec0a2..467e4dc 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -177,6 +177,7 @@ struct d40_base; * @pending_queue: Submitted jobs, to be issued by issue_pending() * @active: Active descriptor. * @queue: Queued jobs. + * @prepare_queue: Prepared jobs. * @dma_cfg: The client configuration of this dma channel. * @configured: whether the dma_cfg configuration is valid * @base: Pointer to the device instance struct. @@ -204,6 +205,7 @@ struct d40_chan { struct list_head pending_queue; struct list_head active; struct list_head queue; + struct list_head prepare_queue; struct stedma40_chan_cfg dma_cfg; bool configured; struct d40_base *base; @@ -833,6 +835,13 @@ static void d40_term_all(struct d40_chan *d40c) d40_desc_free(d40c, d40d); } + /* Release descriptors in prepare queue */ + if (!list_empty(&d40c->prepare_queue)) + list_for_each_entry_safe(d40d, _d, + &d40c->prepare_queue, node) { + d40_desc_remove(d40d); + d40_desc_free(d40c, d40d); + } d40c->pending_tx = 0; d40c->busy = false; @@ -1911,6 +1920,12 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src, goto err; } + /* + * add descriptor to the prepare queue in order to be able + * to free them later in terminate_all + */ + list_add_tail(&desc->node, &chan->prepare_queue); + spin_unlock_irqrestore(&chan->lock, flags); return &desc->txd; @@ -2400,6 +2415,7 @@ static void __init d40_chan_init(struct d40_base *base, struct dma_device *dma, INIT_LIST_HEAD(&d40c->queue); INIT_LIST_HEAD(&d40c->pending_queue); INIT_LIST_HEAD(&d40c->client); + INIT_LIST_HEAD(&d40c->prepare_queue); tasklet_init(&d40c->tasklet, dma_tasklet, (unsigned long) d40c);