From: Arnd Bergmann <arnd@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Wesley Cheng <quic_wcheng@quicinc.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] ALSA: qc_audio_offload: avoid leaking xfer_buf allocation
Date: Tue, 13 May 2025 14:34:41 +0200 [thread overview]
Message-ID: <20250513123442.159936-3-arnd@kernel.org> (raw)
In-Reply-To: <20250513123442.159936-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
The info->xfer_buf_cpu member is set to a NULL value because the
allocation happens in a different function and is only assigned
to the function argument but never passed back.
Pass it by reference instead to have a handle that can actually be
freed by the final usb_free_coherent() call.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
sound/usb/qcom/qc_audio_offload.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
index d2256a26eaaa..c4dde2fa5a1f 100644
--- a/sound/usb/qcom/qc_audio_offload.c
+++ b/sound/usb/qcom/qc_audio_offload.c
@@ -1014,10 +1014,11 @@ static int enable_audio_stream(struct snd_usb_substream *subs,
*
*/
static int uaudio_transfer_buffer_setup(struct snd_usb_substream *subs,
- u8 *xfer_buf, u32 xfer_buf_len,
+ void **xfer_buf_cpu, u32 xfer_buf_len,
struct mem_info_v01 *mem_info)
{
struct sg_table xfer_buf_sgt;
+ void *xfer_buf;
phys_addr_t xfer_buf_pa;
u32 len = xfer_buf_len;
bool dma_coherent;
@@ -1060,6 +1061,7 @@ static int uaudio_transfer_buffer_setup(struct snd_usb_substream *subs,
mem_info->dma = xfer_buf_pa;
mem_info->size = len;
mem_info->iova = PREPEND_SID_TO_IOVA(iova, uaudio_qdev->data->sid);
+ *xfer_buf_cpu = xfer_buf;
sg_free_table(&xfer_buf_sgt);
return 0;
@@ -1340,7 +1342,7 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
struct q6usb_offload *data;
int pcm_dev_num;
int card_num;
- u8 *xfer_buf_cpu = NULL;
+ void *xfer_buf_cpu;
int ret;
pcm_dev_num = (req_msg->usb_token & QMI_STREAM_REQ_DEV_NUM_MASK) >> 8;
@@ -1409,7 +1411,7 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
resp->speed_info_valid = 1;
- ret = uaudio_transfer_buffer_setup(subs, xfer_buf_cpu, req_msg->xfer_buff_size,
+ ret = uaudio_transfer_buffer_setup(subs, &xfer_buf_cpu, req_msg->xfer_buff_size,
&resp->xhci_mem_info.xfer_buff);
if (ret < 0) {
ret = -ENOMEM;
--
2.39.5
next prev parent reply other threads:[~2025-05-13 12:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 12:34 [PATCH 0/3] ALSA: qc_audio_offload: address space cleanups Arnd Bergmann
2025-05-13 12:34 ` [PATCH 1/3] ALSA: qc_audio_offload: rename dma/iova/va/cpu/phys variables Arnd Bergmann
2025-05-13 12:34 ` Arnd Bergmann [this message]
2025-05-13 12:34 ` [PATCH 3/3] ALSA: qc_audio_offload: try to reduce address space confusion Arnd Bergmann
2025-08-01 11:31 ` Luca Weiss
2025-08-01 12:31 ` Takashi Iwai
2025-08-01 12:35 ` Luca Weiss
2025-08-01 12:49 ` Takashi Iwai
2025-09-05 11:47 ` Luca Weiss
2025-09-05 12:08 ` Arnd Bergmann
2025-09-05 13:17 ` Luca Weiss
2025-09-05 14:50 ` Arnd Bergmann
2025-09-05 12:26 ` Takashi Iwai
2025-09-05 14:54 ` Arnd Bergmann
2025-09-05 14:57 ` Takashi Iwai
2025-09-16 8:41 ` Luca Weiss
2025-09-16 16:09 ` Takashi Iwai
2025-09-17 8:19 ` Luca Weiss
2025-09-17 8:30 ` Takashi Iwai
2025-09-17 12:27 ` Luca Weiss
2025-09-17 12:35 ` Takashi Iwai
2025-09-17 12:52 ` Arnd Bergmann
2025-09-17 13:12 ` Takashi Iwai
2025-05-14 9:01 ` [PATCH 0/3] ALSA: qc_audio_offload: address space cleanups Takashi Iwai
2025-05-21 12:33 ` Greg Kroah-Hartman
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=20250513123442.159936-3-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=quic_wcheng@quicinc.com \
--cc=tiwai@suse.com \
/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.