linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Vinod Koul <vkoul@kernel.org>, Sasha Levin <sashal@kernel.org>,
	dmaengine@vger.kernel.org
Subject: [PATCH AUTOSEL 5.7 03/40] dmaengine: ti: k3-udma: Fix cleanup code for alloc_chan_resources
Date: Mon, 20 Jul 2020 17:36:38 -0400	[thread overview]
Message-ID: <20200720213715.406997-3-sashal@kernel.org> (raw)
In-Reply-To: <20200720213715.406997-1-sashal@kernel.org>

From: Peter Ujfalusi <peter.ujfalusi@ti.com>

[ Upstream commit 5a9377cc7421b59b13c9b90b8dc0aca332a1c958 ]

Some of the earlier errors should be sent to the error cleanup path to
make sure that the uchan struct is reset, the dma_pool (if allocated) is
released and memcpy channel pairs are released in a correct way.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200527070612.636-2-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/dma/ti/k3-udma.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index a90e154b0ae0d..2e20fab413b94 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1773,7 +1773,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 			dev_err(ud->ddev.dev,
 				"Descriptor pool allocation failed\n");
 			uc->use_dma_pool = false;
-			return -ENOMEM;
+			ret = -ENOMEM;
+			goto err_cleanup;
 		}
 	}
 
@@ -1793,16 +1794,18 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 
 		ret = udma_get_chan_pair(uc);
 		if (ret)
-			return ret;
+			goto err_cleanup;
 
 		ret = udma_alloc_tx_resources(uc);
-		if (ret)
-			return ret;
+		if (ret) {
+			udma_put_rchan(uc);
+			goto err_cleanup;
+		}
 
 		ret = udma_alloc_rx_resources(uc);
 		if (ret) {
 			udma_free_tx_resources(uc);
-			return ret;
+			goto err_cleanup;
 		}
 
 		uc->config.src_thread = ud->psil_base + uc->tchan->id;
@@ -1820,10 +1823,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 			uc->id);
 
 		ret = udma_alloc_tx_resources(uc);
-		if (ret) {
-			uc->config.remote_thread_id = -1;
-			return ret;
-		}
+		if (ret)
+			goto err_cleanup;
 
 		uc->config.src_thread = ud->psil_base + uc->tchan->id;
 		uc->config.dst_thread = uc->config.remote_thread_id;
@@ -1840,10 +1841,8 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 			uc->id);
 
 		ret = udma_alloc_rx_resources(uc);
-		if (ret) {
-			uc->config.remote_thread_id = -1;
-			return ret;
-		}
+		if (ret)
+			goto err_cleanup;
 
 		uc->config.src_thread = uc->config.remote_thread_id;
 		uc->config.dst_thread = (ud->psil_base + uc->rchan->id) |
@@ -1858,7 +1857,9 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 		/* Can not happen */
 		dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n",
 			__func__, uc->id, uc->config.dir);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto err_cleanup;
+
 	}
 
 	/* check if the channel configuration was successful */
@@ -1938,7 +1939,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
 err_res_free:
 	udma_free_tx_resources(uc);
 	udma_free_rx_resources(uc);
-
+err_cleanup:
 	udma_reset_uchan(uc);
 
 	if (uc->use_dma_pool) {
-- 
2.25.1


  parent reply	other threads:[~2020-07-20 21:37 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 21:36 [PATCH AUTOSEL 5.7 01/40] HID: i2c-hid: add Mediacom FlexBook edge13 to descriptor override Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 02/40] HID: alps: support devices with report id 2 Sasha Levin
2020-07-20 21:36 ` Sasha Levin [this message]
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 04/40] dmaengine: ti: k3-udma: Fix the running channel handling in alloc_chan_resources Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 05/40] HID: steam: fixes race in handling device list Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 06/40] dmaengine: ti: k3-udma: add missing put_device() call in of_xudma_dev_get() Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 07/40] dmaengine: idxd: fix hw descriptor fields for delta record Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 08/40] HID: apple: Disable Fn-key key-re-mapping on clone keyboards Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 09/40] dmaengine: tegra210-adma: Fix runtime PM imbalance on error Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 10/40] soc: amlogic: meson-gx-socinfo: Fix S905X3 and S905D3 ID's Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 11/40] Input: add `SW_MACHINE_COVER` Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 12/40] ARM: dts: n900: remove mmc1 card detect gpio Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 13/40] spi: mediatek: use correct SPI_CFG2_REG MACRO Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 14/40] regmap: dev_get_regmap_match(): fix string comparison Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 15/40] hwmon: (aspeed-pwm-tacho) Avoid possible buffer overflow Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 16/40] dmaengine: fsl-edma: fix wrong tcd endianness for big-endian cpu Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 17/40] dmaengine: ioat setting ioat timeout as module parameter Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 18/40] Input: synaptics - enable InterTouch for ThinkPad X1E 1st gen Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 19/40] Input: elan_i2c - only increment wakeup count on touch Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 20/40] usb: dwc3: pci: add support for the Intel Tiger Lake PCH -H variant Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 21/40] usb: dwc3: pci: add support for the Intel Jasper Lake Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 22/40] usb: gadget: udc: gr_udc: fix memleak on error handling path in gr_ep_init() Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 23/40] usb: cdns3: ep0: fix some endian issues Sasha Levin
2020-07-20 21:36 ` [PATCH AUTOSEL 5.7 24/40] usb: cdns3: trace: " Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 25/40] hwmon: (adm1275) Make sure we are reading enough data for different chips Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 26/40] drm/amdgpu/gfx10: fix race condition for kiq Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 27/40] drm/amdgpu: fix preemption unit test Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 28/40] hwmon: (nct6775) Accept PECI Calibration as temperature source for NCT6798D Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 29/40] platform/x86: ISST: Add new PCI device ids Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 30/40] platform/x86: asus-wmi: allow BAT1 battery name Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 31/40] hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe() Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 32/40] ALSA: hda/realtek - fixup for yet another Intel reference board Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 33/40] drivers/perf: Fix kernel panic when rmmod PMU modules during perf sampling Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 34/40] arm64: Use test_tsk_thread_flag() for checking TIF_SINGLESTEP Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 35/40] x86: math-emu: Fix up 'cmp' insn for clang ias Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 36/40] asm-generic/mmiowb: Allow mmiowb_set_pending() when preemptible() Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 37/40] drivers/perf: Prevent forced unbinding of PMU drivers Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 38/40] RISC-V: Upgrade smp_mb__after_spinlock() to iorw,iorw Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 39/40] SUNRPC reverting d03727b248d0 ("NFSv4 fix CLOSE not waiting for direct IO compeletion") Sasha Levin
2020-07-20 21:37 ` [PATCH AUTOSEL 5.7 40/40] x86/boot: Don't add the EFI stub to targets Sasha Levin

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=20200720213715.406997-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@ti.com \
    --cc=stable@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /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).