Skip to contentSkip to conversation

ENOMEM detection fix in 16550A driver

Xenomai-core Applied Jan Kiszka 2 participants 2 messages Nov 25, 2005

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

Hi all,

that's what reusing drivers also gives us: Paolo found a small but ugly bug in the 16550A driver, see attached fix and Changelog (for both 2.0.x and 2.1.x).

Jan

ChangeLog +5 -0
Index: ChangeLog
===================================================================
@@ -1,3 +1,8 @@
+2005-11-25  Jan Kiszka <[email protected]>
+
+	* drivers/16550A/16550A.c (RTSER_RTIOC_SET_CONFIG): Fix ENOMEM detection
+        (once again). Found by Paolo Mantegazza through cross-usage.
+
 2005-11-21  Philippe Gerum  <[email protected]>
 
 	* skins/native, nucleus/pipe.c: Globally replace ENOSPC by
16550A/16550A.c +3 -4
Index: drivers/16550A/16550A.c
===================================================================
@@ -587,10 +587,9 @@
                     else
                         hist_buf =
                             rtdm_malloc(IN_BUFFER_SIZE * sizeof(uint64_t));
+                    if (!hist_buf)
+                        return -ENOMEM;
                 }
-
-                if (!hist_buf)
-                    return -ENOMEM;
             }
 
             rt_16550_set_config(ctx, config, &hist_buf);
@@ -1025,7 +1024,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "rt_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 0),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
drivers/16550A/16550A.c +3 -4
Index: ksrc/drivers/16550A/16550A.c
===================================================================
@@ -589,10 +589,9 @@
                     else
                         hist_buf =
                             rtdm_malloc(IN_BUFFER_SIZE * sizeof(uint64_t));
+                    if (!hist_buf)
+                        return -ENOMEM;
                 }
-
-                if (!hist_buf)
-                    return -ENOMEM;
             }
 
             rt_16550_set_config(ctx, config, &hist_buf);
@@ -1027,7 +1026,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "rt_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 0),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
#1 lore raw
Quoted 5 lines · Jan Kiszka

Hi all,

that's what reusing drivers also gives us: Paolo found a small but ugly bug in the 16550A driver, see attached fix and Changelog (for both 2.0.x and 2.1.x).

Applied, thanks.

Quoted 84 lines

Jan

------------------------------------------------------------------------

Index: ChangeLog
===================================================================

ChangeLog +5 -0
@@ -1,3 +1,8 @@
+2005-11-25  Jan Kiszka <[email protected]>
+
+	* drivers/16550A/16550A.c (RTSER_RTIOC_SET_CONFIG): Fix ENOMEM detection
+        (once again). Found by Paolo Mantegazza through cross-usage.
+
 2005-11-21  Philippe Gerum  <[email protected]>
 
 	* skins/native, nucleus/pipe.c: Globally replace ENOSPC by

Index: drivers/16550A/16550A.c
===================================================================

16550A/16550A.c +3 -5
@@ -587,10 +587,9 @@
                     else
                         hist_buf =
                             rtdm_malloc(IN_BUFFER_SIZE * sizeof(uint64_t));
+                    if (!hist_buf)
+                        return -ENOMEM;
                 }
-
-                if (!hist_buf)
-                    return -ENOMEM;
             }
 
             rt_16550_set_config(ctx, config, &hist_buf);
@@ -1025,7 +1024,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "rt_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 0),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
 
 
------------------------------------------------------------------------

Index: ksrc/drivers/16550A/16550A.c
===================================================================

drivers/16550A/16550A.c +3 -5
@@ -589,10 +589,9 @@
                     else
                         hist_buf =
                             rtdm_malloc(IN_BUFFER_SIZE * sizeof(uint64_t));
+                    if (!hist_buf)
+                        return -ENOMEM;
                 }
-
-                if (!hist_buf)
-                    return -ENOMEM;
             }
 
             rt_16550_set_config(ctx, config, &hist_buf);
@@ -1027,7 +1026,7 @@
     device_class:       RTDM_CLASS_SERIAL,
     device_sub_class:   RTDM_SUBCLASS_16550A,
     driver_name:        "rt_16550A",
-    driver_version:     RTDM_DRIVER_VER(1, 2, 0),
+    driver_version:     RTDM_DRIVER_VER(1, 2, 1),
     peripheral_name:    "UART 16550A",
     provider_name:      "Jan Kiszka",
 };
 
 
------------------------------------------------------------------------

_______________________________________________
Xenomai-core mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-core

Signature · 1 line
Philippe.