]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/term/ieee1275/serial.c (do_real_config): Set handle to
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 8 Jun 2012 17:34:57 +0000 (19:34 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 8 Jun 2012 17:34:57 +0000 (19:34 +0200)
invalid on error.
(serial_hw_fetch): Don't read invalid handle.
(serial_hw_put): Don't write into invalid handle.

ChangeLog
grub-core/term/ieee1275/serial.c

index 80e79296733375b5461d21bc8ef3cf70107d5e49..aa2e076977aab3151c4d4b5f08fcfab392095bd3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-08  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * 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  <phcoder@gmail.com>
 
        Add a 1.5 stop bits value.
index 58253c55e2cdaa8f6421af6046b4fa59c3ab1fa2..cf4be59464a8be14b6ac6fb722eb2f945901ea52 100644 (file)
@@ -24,6 +24,8 @@
 #include <grub/time.h>
 #include <grub/i18n.h>
 
+#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);
 }