From: "Martin Povišer" <povik+lin@cutebit.org>
To: Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
Vinod Koul <vkoul@kernel.org>
Cc: "Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Martin Povišer" <povik+lin@cutebit.org>,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed
Date: Fri, 24 Feb 2023 16:22:21 +0100 [thread overview]
Message-ID: <20230224152222.26732-2-povik+lin@cutebit.org> (raw)
In-Reply-To: <20230224152222.26732-1-povik+lin@cutebit.org>
In terminate_all we should queue up all submitted descriptors to be
freed. We do that for the content of the 'issued' and 'submitted' lists,
but the 'current_tx' descriptor falls through the cracks as it's
removed from the 'issued' list once it gets assigned to be the current
descriptor. Explicitly queue up freeing of the 'current_tx' descriptor
to address a memory leak that is otherwise present.
Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
drivers/dma/apple-admac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 00cbfafe0ed9..497bb65b7d6d 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan)
admac_stop_chan(adchan);
admac_reset_rings(adchan);
- adchan->current_tx = NULL;
+ if (adchan->current_tx) {
+ list_add_tail(&adchan->current_tx->node, &adchan->to_free);
+ adchan->current_tx = NULL;
+ }
/*
* Descriptors can only be freed after the tasklet
* has been killed (in admac_synchronize).
--
2.33.0
WARNING: multiple messages have this Message-ID (diff)
From: "Martin Povišer" <povik+lin@cutebit.org>
To: Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
Vinod Koul <vkoul@kernel.org>
Cc: "Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Martin Povišer" <povik+lin@cutebit.org>,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed
Date: Fri, 24 Feb 2023 16:22:21 +0100 [thread overview]
Message-ID: <20230224152222.26732-2-povik+lin@cutebit.org> (raw)
In-Reply-To: <20230224152222.26732-1-povik+lin@cutebit.org>
In terminate_all we should queue up all submitted descriptors to be
freed. We do that for the content of the 'issued' and 'submitted' lists,
but the 'current_tx' descriptor falls through the cracks as it's
removed from the 'issued' list once it gets assigned to be the current
descriptor. Explicitly queue up freeing of the 'current_tx' descriptor
to address a memory leak that is otherwise present.
Fixes: b127315d9a78 ("dmaengine: apple-admac: Add Apple ADMAC driver")
Signed-off-by: Martin Povišer <povik+lin@cutebit.org>
---
drivers/dma/apple-admac.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 00cbfafe0ed9..497bb65b7d6d 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -512,7 +512,10 @@ static int admac_terminate_all(struct dma_chan *chan)
admac_stop_chan(adchan);
admac_reset_rings(adchan);
- adchan->current_tx = NULL;
+ if (adchan->current_tx) {
+ list_add_tail(&adchan->current_tx->node, &adchan->to_free);
+ adchan->current_tx = NULL;
+ }
/*
* Descriptors can only be freed after the tasklet
* has been killed (in admac_synchronize).
--
2.33.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-24 15:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 15:22 [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Martin Povišer
2023-02-24 15:22 ` Martin Povišer
2023-02-24 15:22 ` Martin Povišer [this message]
2023-02-24 15:22 ` [PATCH 2/3] dmaengine: apple-admac: Fix 'current_tx' not getting freed Martin Povišer
2023-02-24 15:22 ` [PATCH 3/3] dmaengine: apple-admac: Set src_addr_widths capability Martin Povišer
2023-02-24 15:22 ` Martin Povišer
2023-03-31 12:47 ` [PATCH 1/3] dmaengine: apple-admac: Handle 'global' interrupt flags Vinod Koul
2023-03-31 12:47 ` 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=20230224152222.26732-2-povik+lin@cutebit.org \
--to=povik+lin@cutebit.org \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=dmaengine@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=sven@svenpeter.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.