* [PATCH] accel/qaic: Free the DBC buffer on management transfer errors
@ 2026-11-28 9:33 Haoxiang Li
2026-11-28 9:44 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Haoxiang Li @ 2026-11-28 9:33 UTC (permalink / raw)
To: jeff.hugo, carl.vanderlip, ogabbay, jacek.lawrynowicz,
quic_pkanojiy
Cc: linux-arm-msm, dri-devel, Haoxiang Li
encode_message() may allocate a buffer in encode_activate(). The
buffer should be freed if something fails later in qaic_manage_msg_xfer().
Add free_dbc_buf() under label lock_failed to do so and retain it
on success for here because the buffer should not be freed if no
failure.
Fixes: 129776ac2e38 ("accel/qaic: Add control path")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
drivers/accel/qaic/qaic_control.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
index 2ccc55486aac..f322887ec53e 100644
--- a/drivers/accel/qaic/qaic_control.c
+++ b/drivers/accel/qaic/qaic_control.c
@@ -1250,6 +1250,8 @@ static int qaic_manage_msg_xfer(struct qaic_device *qdev, struct qaic_user *usr,
lock_failed:
free_dma_xfers(qdev, resources);
+ if (ret)
+ free_dbc_buf(qdev, resources);
encode_failed:
spin_lock(&wrappers->lock);
list_for_each_entry_safe(wrapper, w, &wrappers->list, list)
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] accel/qaic: Free the DBC buffer on management transfer errors
2026-11-28 9:33 [PATCH] accel/qaic: Free the DBC buffer on management transfer errors Haoxiang Li
@ 2026-11-28 9:44 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28 9:44 UTC (permalink / raw)
To: Haoxiang Li; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] accel/qaic: memory leak in encode_activate() [1]
--
commit 48133c97c10bb67d1f23799c52aaf49134fd456e
Author: Haoxiang Li <haoxiang_li2024@163.com>
accel/qaic: Free the DBC buffer on management transfer errors
This commit frees the DBC buffer allocated during message encoding when
a management transfer fails in qaic_manage_msg_xfer().
> diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
> index 2ccc55486aac0..f322887ec53e8 100644
> --- a/drivers/accel/qaic/qaic_control.c
> +++ b/drivers/accel/qaic/qaic_control.c
> @@ -1250,6 +1250,8 @@ static int qaic_manage_msg_xfer(struct qaic_device *qdev, struct qaic_user *usr,
>
> lock_failed:
> free_dma_xfers(qdev, resources);
> + if (ret)
> + free_dbc_buf(qdev, resources);
> encode_failed:
> spin_lock(&wrappers->lock);
> list_for_each_entry_safe(wrapper, w, &wrappers->list, list)
[Severity: High]
This problem wasn't introduced by this patch, but can encode_activate()
leak the DMA buffer in resources->buf [1] when a management message
contains more than one QAIC_TRANS_ACTIVATE_FROM_USR transaction?
encode_message() loops over user_msg->count transactions and calls
encode_activate() for each QAIC_TRANS_ACTIVATE_FROM_USR entry. Each call
allocates a coherent DMA buffer and overwrites resources->buf and
resources->dma_addr without checking whether a buffer was already
allocated for an earlier transaction in the same ioctl:
drivers/accel/qaic/qaic_control.c:encode_activate() {
...
buf = dma_alloc_coherent(&qdev->pdev->dev, size, &dma_addr, GFP_KERNEL);
if (!buf)
return -ENOMEM;
...
resources->buf = buf;
resources->dma_addr = dma_addr;
...
}
Any earlier allocation in the same message is lost and cannot be freed by
free_dbc_buf(), allowing userspace to exhaust coherent DMA memory.
[1] https://sashiko.dev/#/bug/linux-ad70f5f2-e579-4654-84f6-691a5c89ecc1
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261128093322.1217738-1-haoxiang_li2024@163.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 9:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 9:33 [PATCH] accel/qaic: Free the DBC buffer on management transfer errors Haoxiang Li
2026-11-28 9:44 ` sashiko-bot
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.