You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/10/22 02:21:11 UTC
(nuttx) 06/10: drivers/virtio-snd: finish with the buffer before dequeuing it
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 41ce57825aa2d55637ba734bd1f2013a96d5133c
Author: hanqiyuan <ha...@xiaomi.com>
AuthorDate: Tue Jul 1 20:08:58 2025 +0800
drivers/virtio-snd: finish with the buffer before dequeuing it
AUDIO_CALLBACK_DEQUEUE hands the buffer back to the upper half, which
may free it on another CPU at once, yet buf->dev and buf->status were
read after the callback. Move the callback after the last use.
Signed-off-by: hanqiyuan <ha...@xiaomi.com>
---
drivers/virtio/virtio-snd.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/virtio/virtio-snd.c b/drivers/virtio/virtio-snd.c
index 2c9246d0d96..0fbc220fdaa 100644
--- a/drivers/virtio/virtio-snd.c
+++ b/drivers/virtio/virtio-snd.c
@@ -352,13 +352,6 @@ static void virtio_snd_pcm_notify_cb(FAR struct virtqueue *vq)
break;
}
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_DEQUEUE,
- &buf->apb, OK, NULL);
-#else
- buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_DEQUEUE,
- &buf->apb, OK);
-#endif
sdev = (FAR struct virtio_snd_dev_s *)buf->dev;
sdev->cache_buffers--;
if (sdev->running &&
@@ -367,6 +360,14 @@ static void virtio_snd_pcm_notify_cb(FAR struct virtqueue *vq)
buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_UNDERRUN,
NULL, OK);
}
+
+#ifdef CONFIG_AUDIO_MULTI_SESSION
+ buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_DEQUEUE,
+ &buf->apb, OK, NULL);
+#else
+ buf->dev->upper(buf->dev->priv, AUDIO_CALLBACK_DEQUEUE,
+ &buf->apb, OK);
+#endif
}
spin_unlock_irqrestore(&priv->lock, flags);