Skip to contentSkip to conversation

char: serial: check divider value against baud base

PATCH Applied P J P 2 participants 2 messages Oct 12, 2016

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH v2 1/1 char: serial: check divider value against baud base

From: Prasad J Pandit <[email protected]>

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.

---
 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

hw/char/serial.c +2 -1
index 3442f47..eec72b7 100644
@@ -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;
Signature · 1 line
2.5.5
#1 lore raw
Quoted 23 lines · P J P

From: Prasad J Pandit <[email protected]>

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.

---
 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

hw/char/serial.c +0 -0
index 3442f47..eec72b7 100644

hw/char/serial.c static void serial_update_parameters(SerialState *s) · line 161

Quoted 10 lines
hw/char/serial.c +2 -1
@@ -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