From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buEfR-0001VY-8l for qemu-devel@nongnu.org; Wed, 12 Oct 2016 04:13:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buEfM-0000Hd-Rw for qemu-devel@nongnu.org; Wed, 12 Oct 2016 04:13:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buEfM-0000HZ-Ky for qemu-devel@nongnu.org; Wed, 12 Oct 2016 04:13:32 -0400 References: <1476251888-20238-1-git-send-email-ppandit@redhat.com> From: Paolo Bonzini Message-ID: <9becea85-2bd3-98be-431c-e20e4a1ab0ec@redhat.com> Date: Wed, 12 Oct 2016 10:13:27 +0200 MIME-Version: 1.0 In-Reply-To: <1476251888-20238-1-git-send-email-ppandit@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] char: serial: check divider value against baud base List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: P J P , Qemu Developers Cc: "Michael S. Tsirkin" , Huawei PSIRT , Prasad J Pandit On 12/10/2016 07:58, P J P wrote: > 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 > --- > hw/char/serial.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > Update per > -> https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg02400.html > > 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; > Queued, thanks. Paolo