From 08fd12913716ef1ddd2c7b1c7b490815fd7a6e60 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 8 Jun 2012 19:34:57 +0200 Subject: [PATCH] * grub-core/term/ieee1275/serial.c (do_real_config): Set handle to invalid on error. (serial_hw_fetch): Don't read invalid handle. (serial_hw_put): Don't write into invalid handle. --- ChangeLog | 7 +++++++ grub-core/term/ieee1275/serial.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 80e792967..aa2e07697 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-06-08 Vladimir Serbinenko + + * grub-core/term/ieee1275/serial.c (do_real_config): Set handle to + invalid on error. + (serial_hw_fetch): Don't read invalid handle. + (serial_hw_put): Don't write into invalid handle. + 2012-06-08 Vladimir Serbinenko Add a 1.5 stop bits value. diff --git a/grub-core/term/ieee1275/serial.c b/grub-core/term/ieee1275/serial.c index 58253c55e..cf4be5946 100644 --- a/grub-core/term/ieee1275/serial.c +++ b/grub-core/term/ieee1275/serial.c @@ -24,6 +24,8 @@ #include #include +#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0) + struct ofserial_hash_ent { char *devpath; @@ -39,7 +41,9 @@ do_real_config (struct grub_serial_port *port) if (port->configured) return; - grub_ieee1275_open (port->elem->devpath, &port->handle); + if (grub_ieee1275_open (port->elem->devpath, &port->handle) + || port->handle == (grub_ieee1275_cell_t) -1) + port->handle = IEEE1275_IHANDLE_INVALID; port->configured = 1; } @@ -53,6 +57,8 @@ serial_hw_fetch (struct grub_serial_port *port) do_real_config (port); + if (port->handle == IEEE1275_IHANDLE_INVALID) + return -1; grub_ieee1275_read (port->handle, &c, 1, &actual); if (actual <= 0) @@ -69,6 +75,9 @@ serial_hw_put (struct grub_serial_port *port, const int c) do_real_config (port); + if (port->handle == IEEE1275_IHANDLE_INVALID) + return; + grub_ieee1275_write (port->handle, &c0, 1, &actual); }