Commit 3592fe0c authored by Prasad J Pandit's avatar Prasad J Pandit Committed by Paolo Bonzini
Browse files

char: serial: check divider value against baud base



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: default avatarHuawei PSIRT <psirt@huawei.com>
Signed-off-by: default avatarPrasad J Pandit <pjp@fedoraproject.org>
Message-Id: <1476251888-20238-1-git-send-email-ppandit@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0a752eee
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;