Received: from eggs.gnu.org ([2001:4830:134:3::10]:46663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byfbh-0004A2-JC for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byfbd-0006O4-Qm for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:05 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34300) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byfbd-0006Nc-LI for qemu-devel@nongnu.org; Mon, 24 Oct 2016 09:48:01 -0400 Received: by mail-wm0-x241.google.com with SMTP id d199so9946600wmd.1 for ; Mon, 24 Oct 2016 06:48:01 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 24 Oct 2016 15:47:03 +0200 Message-Id: <1477316855-42218-19-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> References: <1477316855-42218-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 18/50] char: serial: check divider value against baud base List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Prasad J Pandit From: Prasad J Pandit 16550A UART device uses an oscillator to generate frequencies (baud base), which decide communication speed. This speed could be changed by dividing it by a divider. If the divider is greater than the baud base, speed is set to zero, leading to a divide by zero error. Add check to avoid it. Reported-by: Huawei PSIRT Signed-off-by: Prasad J Pandit Message-Id: <1476251888-20238-1-git-send-email-ppandit@redhat.com> Signed-off-by: Paolo Bonzini --- hw/char/serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/char/serial.c b/hw/char/serial.c index 3442f47..eec72b7 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -153,8 +153,9 @@ static void serial_update_parameters(SerialState *s) int speed, parity, data_bits, stop_bits, frame_size; QEMUSerialSetParams ssp; - if (s->divider == 0) + if (s->divider == 0 || s->divider > s->baudbase) { return; + } /* Start bit. */ frame_size = 1; -- 1.8.3.1