From: srini@kernel.org
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org,
Guangshuo Li <liguangshuo@mail.sdu.edu.cn>,
stable@vger.kernel.org, Srinivas Kandagatla <srini@kernel.org>
Subject: [PATCH 2/2] slimbus: qcom-ngd-ctrl: Fix potential DMA buffer leaks on teardown
Date: Tue, 1 Dec 2026 23:28:15 +0000 [thread overview]
Message-ID: <20261201232815.537957-3-srini@kernel.org> (raw)
In-Reply-To: <20261201232815.537957-1-srini@kernel.org>
From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
DMA teardown terminates transfers and releases the channels but leaves
the coherent message buffers allocated. A subsequent initialization
overwrites their addresses, and removal loses them permanently.
Free the buffers after terminating DMA. Clear channels released during
initialization failure so teardown cannot free the same resources again.
This issue was found by our static analysis tool under development.
Fixes: 917809e2280b ("slimbus: ngd: Add qcom SLIMBus NGD driver")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
---
drivers/slimbus/qcom-ngd-ctrl.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd-ctrl.c
index 8da75c4b50e5..a29e57303046 100644
--- a/drivers/slimbus/qcom-ngd-ctrl.c
+++ b/drivers/slimbus/qcom-ngd-ctrl.c
@@ -706,9 +706,12 @@ static int qcom_slim_ngd_init_rx_msgq(struct qcom_slim_ngd_ctrl *ctrl)
return 0;
rx_post_err:
+ dmaengine_terminate_sync(ctrl->dma_rx_channel);
dma_free_coherent(dev, size, ctrl->rx_base, ctrl->rx_phys_base);
+ ctrl->rx_base = NULL;
rel_rx:
dma_release_channel(ctrl->dma_rx_channel);
+ ctrl->dma_rx_channel = NULL;
return ret;
}
@@ -743,6 +746,7 @@ static int qcom_slim_ngd_init_tx_msgq(struct qcom_slim_ngd_ctrl *ctrl)
return 0;
rel_tx:
dma_release_channel(ctrl->dma_tx_channel);
+ ctrl->dma_tx_channel = NULL;
return ret;
}
@@ -1210,11 +1214,19 @@ static int qcom_slim_ngd_exit_dma(struct qcom_slim_ngd_ctrl *ctrl)
{
if (ctrl->dma_rx_channel) {
dmaengine_terminate_sync(ctrl->dma_rx_channel);
+ dma_free_coherent(ctrl->dev,
+ QCOM_SLIM_NGD_DESC_NUM * SLIM_MSGQ_BUF_LEN,
+ ctrl->rx_base, ctrl->rx_phys_base);
+ ctrl->rx_base = NULL;
dma_release_channel(ctrl->dma_rx_channel);
}
if (ctrl->dma_tx_channel) {
dmaengine_terminate_sync(ctrl->dma_tx_channel);
+ dma_free_coherent(ctrl->dev,
+ (QCOM_SLIM_NGD_DESC_NUM + 1) * SLIM_MSGQ_BUF_LEN,
+ ctrl->tx_base, ctrl->tx_phys_base);
+ ctrl->tx_base = NULL;
dma_release_channel(ctrl->dma_tx_channel);
}
--
2.53.0
prev parent reply other threads:[~2026-12-01 23:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 23:28 [PATCH 0/2] slimbus: fixes for v7.4 srini
2026-12-01 23:28 ` [PATCH 1/2] slimbus: messaging: hold lock until transaction is completed srini
2026-12-01 23:28 ` srini [this message]
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=20261201232815.537957-3-srini@kernel.org \
--to=srini@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.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.