dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai3@huawei.com>
To: <ludovic.desroches@microchip.com>, <tudor.ambarus@microchip.com>,
	<vkoul@kernel.org>, <dan.j.williams@intel.com>,
	<nicolas.ferre@microchip.com>, <plagnioj@jcrosoft.com>,
	<arnd@arndb.de>
Cc: <linux-arm-kernel@lists.infradead.org>,
	<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<yi.zhang@huawei.com>, <yukuai3@huawei.com>
Subject: [PATCH 2/3] dmaengine: at_hdmac: add missing put_device() call in at_dma_xlate()
Date: Mon, 17 Aug 2020 19:57:27 +0800	[thread overview]
Message-ID: <20200817115728.1706719-3-yukuai3@huawei.com> (raw)
In-Reply-To: <20200817115728.1706719-1-yukuai3@huawei.com>

If of_find_device_by_node() succeed, at_dma_xlate() doesn't have a
corresponding put_device(). Thus add put_device() to fix the exception
handling for this function implementation.

Fixes: bbe89c8e3d59 ("at_hdmac: move to generic DMA binding")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/dma/at_hdmac.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 1c941f839c42..bf874367097c 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1657,8 +1657,10 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 	dma_cap_set(DMA_SLAVE, mask);
 
 	atslave = kmalloc(sizeof(*atslave), GFP_KERNEL);
-	if (!atslave)
+	if (!atslave) {
+		put_device(&dmac_pdev->dev);
 		return NULL;
+	}
 
 	atslave->cfg = ATC_DST_H2SEL_HW | ATC_SRC_H2SEL_HW;
 	/*
@@ -1687,8 +1689,10 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
 	atslave->dma_dev = &dmac_pdev->dev;
 
 	chan = dma_request_channel(mask, at_dma_filter, atslave);
-	if (!chan)
+	if (!chan) {
+		put_device(&dmac_pdev->dev);
 		return NULL;
+	}
 
 	atchan = to_at_dma_chan(chan);
 	atchan->per_if = dma_spec->args[0] & 0xff;
-- 
2.25.4


  parent reply	other threads:[~2020-08-17 11:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-17 11:57 [PATCH V2 0/3] do exception handling appropriately in at_dma_xlate() Yu Kuai
2020-08-17 11:57 ` [PATCH 1/3] dmaengine: at_hdmac: check return value of of_find_device_by_node() " Yu Kuai
2020-08-17 11:57 ` Yu Kuai [this message]
2020-08-17 11:57 ` [PATCH 3/3] dmaengine: at_hdmac: add missing kfree() call " Yu Kuai
2020-08-19  4:29 ` [PATCH V2 0/3] do exception handling appropriately " Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200817115728.1706719-3-yukuai3@huawei.com \
    --to=yukuai3@huawei.com \
    --cc=arnd@arndb.de \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=tudor.ambarus@microchip.com \
    --cc=vkoul@kernel.org \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).