From patchwork Mon Apr 19 08:39:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 93437 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3J8dgKX005355 for ; Mon, 19 Apr 2010 08:39:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751781Ab0DSIjm (ORCPT ); Mon, 19 Apr 2010 04:39:42 -0400 Received: from mail.gmx.net ([213.165.64.20]:55522 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751382Ab0DSIjl (ORCPT ); Mon, 19 Apr 2010 04:39:41 -0400 Received: (qmail invoked by alias); 19 Apr 2010 08:39:39 -0000 Received: from p57BD1B6F.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.27.111] by mail.gmx.net (mp071) with SMTP; 19 Apr 2010 10:39:39 +0200 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX18s9JoNZlkswCfCL/6LD2yy8/0qNsCjvDU+AH1Cea 1UoSwvAhZJCEOn Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1O3mW3-0001IF-9S; Mon, 19 Apr 2010 10:39:39 +0200 Date: Mon, 19 Apr 2010 10:39:39 +0200 (CEST) From: Guennadi Liakhovetski To: "linux-sh@vger.kernel.org" , Dan Williams Subject: [PATCH] SH: fix error paths in DMA driver Message-ID: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 19 Apr 2010 08:39:42 +0000 (UTC) diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c index bbc3dfe..549bae9 100644 --- a/drivers/dma/shdma.c +++ b/drivers/dma/shdma.c @@ -288,6 +288,7 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) struct sh_dmae_chan *sh_chan = to_sh_chan(chan); struct sh_desc *desc; struct sh_dmae_slave *param = chan->private; + int ret; pm_runtime_get_sync(sh_chan->dev); @@ -299,11 +300,15 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) struct sh_dmae_slave_config *cfg; cfg = sh_dmae_find_slave(sh_chan, param); - if (!cfg) - return -EINVAL; + if (!cfg) { + ret = -EINVAL; + goto efindslave; + } - if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) - return -EBUSY; + if (test_and_set_bit(param->slave_id, sh_dmae_slave_used)) { + ret = -EBUSY; + goto etestused; + } param->config = cfg; @@ -332,10 +337,20 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan) } spin_unlock_bh(&sh_chan->desc_lock); - if (!sh_chan->descs_allocated) - pm_runtime_put(sh_chan->dev); + if (!sh_chan->descs_allocated) { + ret = -ENOMEM; + goto edescalloc; + } return sh_chan->descs_allocated; + +edescalloc: + if (param) + clear_bit(param->slave_id, sh_dmae_slave_used); +etestused: +efindslave: + pm_runtime_put(sh_chan->dev); + return ret; } /*