Received: from eggs.gnu.org ([2001:4830:134:3::10]:35309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtu3q-0005MS-ML for qemu-devel@nongnu.org; Mon, 18 Sep 2017 07:17:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtu3m-00054x-KQ for qemu-devel@nongnu.org; Mon, 18 Sep 2017 07:17:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtu3m-00054e-EF for qemu-devel@nongnu.org; Mon, 18 Sep 2017 07:17:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DFC4356F6 for ; Mon, 18 Sep 2017 11:17:53 +0000 (UTC) From: Gerd Hoffmann Date: Mon, 18 Sep 2017 13:17:49 +0200 Message-Id: <20170918111750.15965-2-kraxel@redhat.com> In-Reply-To: <20170918111750.15965-1-kraxel@redhat.com> References: <20170918111750.15965-1-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/2] wm8750: add record buffer underrun check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Reported-by: niuguoxiang@huawei.com Signed-off-by: Gerd Hoffmann Message-id: 20170901131409.6712-1-kraxel@redhat.com --- hw/audio/wm8750.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c index f8b5bebfc2..d2bf2e1da1 100644 --- a/hw/audio/wm8750.c +++ b/hw/audio/wm8750.c @@ -680,8 +680,12 @@ uint32_t wm8750_adc_dat(void *opaque) WM8750State *s = (WM8750State *) opaque; uint32_t *data; - if (s->idx_in >= sizeof(s->data_in)) + if (s->idx_in >= sizeof(s->data_in)) { wm8750_in_load(s); + if (s->idx_in >= sizeof(s->data_in)) { + return 0x80008000; /* silence in AUD_FMT_S16 sample format */ + } + } data = (uint32_t *) &s->data_in[s->idx_in]; s->req_in -= 4; -- 2.9.3