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 <[email protected]> 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 <[email protected]> --- 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);
