[Qemu-devel] [PATCH] audio: st_rate_flow exist a dead loop

Peng Hao posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1499211867-3126-1-git-send-email-peng.hao2@zte.com.cn
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
audio/rate_template.h | 5 +++++
1 file changed, 5 insertions(+)
[Qemu-devel] [PATCH] audio: st_rate_flow exist a dead loop
Posted by Peng Hao 6 years, 9 months ago
From: Hao Peng <peng.hao2@zte.com.cn>

if audio device is opend for a long time in windows vm, there is a uint32_t varaible reversal.
It will result to a dead loop.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Reviewed-by: Liu Yun <liu.yunh@zte.com.cn>
Reviewed-by: Wang Yechao <wang.yechao255@zte.com.cn>
---
 audio/rate_template.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/audio/rate_template.h b/audio/rate_template.h
index bd4b1c7..1aa6c43 100644
--- a/audio/rate_template.h
+++ b/audio/rate_template.h
@@ -71,6 +71,11 @@ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
         while (rate->ipos <= (rate->opos >> 32)) {
             ilast = *ibuf++;
             rate->ipos++;
+            /* if ipos reversal, there is  a dead loop */
+            if (rate->ipos == 0xffffffff) {
+                rate->ipos = 1;
+                rate->opos = rate->opos & 0xffffffff;
+            }
             /* See if we finished the input buffer yet */
             if (ibuf >= iend) {
                 goto the_end;
-- 
1.8.3.1