public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] dmaengine: Fix client_count is countered one more incorrectly.
@ 2022-08-30  9:32 Koba Ko
  2022-09-02  7:13 ` Jie Hai
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Koba Ko @ 2022-08-30  9:32 UTC (permalink / raw)
  To: Vinod Koul, dmaengine, linux-kernel

If the passed client_count is 0,
it would be incremented by balance_ref_count first
then increment one more.
This would cause client_count to 2.

cat /sys/class/dma/dma0chan*/in_use
2
2
2

Fixes: d2f4f99db3e9 ("dmaengine: Rework dma_chan_get")
Signed-off-by: Koba Ko <koba.ko@canonical.com>
---
 drivers/dma/dmaengine.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 2cfa8458b51be..78f8a9f3ad825 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -451,7 +451,8 @@ static int dma_chan_get(struct dma_chan *chan)
 	/* The channel is already in use, update client count */
 	if (chan->client_count) {
 		__module_get(owner);
-		goto out;
+		chan->client_count++;
+		return 0;
 	}
 
 	if (!try_module_get(owner))
@@ -470,11 +471,11 @@ static int dma_chan_get(struct dma_chan *chan)
 			goto err_out;
 	}
 
+	chan->client_count++;
+
 	if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask))
 		balance_ref_count(chan);
 
-out:
-	chan->client_count++;
 	return 0;
 
 err_out:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-09-30 16:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-30  9:32 [PATCH 3/3] dmaengine: Fix client_count is countered one more incorrectly Koba Ko
2022-09-02  7:13 ` Jie Hai
2022-09-16 15:33 ` Jerry Snitselaar
2022-09-16 15:46 ` Dave Jiang
2022-09-29 16:57 ` Jerry Snitselaar
2022-09-29 17:10   ` Vinod Koul
2022-09-29 17:26     ` Jerry Snitselaar
2022-09-30  4:44       ` Koba Ko
2022-09-30  5:56         ` Jerry Snitselaar
2022-09-30  6:25           ` Koba Ko
2022-09-30 16:17             ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox