[rtems commit] rtems: Avoid NULL pointer access

Sebastian Huber sebh at rtems.org
Thu Jan 10 13:00:15 UTC 2013


Module:    rtems
Branch:    master
Commit:    cf8a351cb193bd20c991803825e5f84d4b7d7735
Changeset: http://git.rtems.org/rtems/commit/?id=cf8a351cb193bd20c991803825e5f84d4b7d7735

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jan 10 14:03:46 2013 +0100

rtems: Avoid NULL pointer access

The _MPCI_table may be NULL in case multiprocessing is disabled in the
application configuration.

---

 cpukit/rtems/src/msgqcreate.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cpukit/rtems/src/msgqcreate.c b/cpukit/rtems/src/msgqcreate.c
index e65dcac..8a7abfa 100644
--- a/cpukit/rtems/src/msgqcreate.c
+++ b/cpukit/rtems/src/msgqcreate.c
@@ -48,7 +48,6 @@ rtems_status_code rtems_message_queue_create(
   CORE_message_queue_Attributes   the_msgq_attributes;
 #if defined(RTEMS_MULTIPROCESSING)
   bool                            is_global;
-  size_t                          max_packet_payload_size;
 #endif
 
   if ( !rtems_is_name_valid( name ) )
@@ -76,11 +75,14 @@ rtems_status_code rtems_message_queue_create(
    * It seems reasonable to create a que with a large max size,
    * and then just send smaller msgs from remote (or all) nodes.
    */
+  if ( is_global ) {
+    size_t max_packet_payload_size = _MPCI_table->maximum_packet_size
+      - MESSAGE_QUEUE_MP_PACKET_SIZE;
 
-  max_packet_payload_size = _MPCI_table->maximum_packet_size
-    - MESSAGE_QUEUE_MP_PACKET_SIZE;
-  if ( is_global && max_packet_payload_size < max_message_size )
-    return RTEMS_INVALID_SIZE;
+    if ( max_message_size > max_packet_payload_size ) {
+      return RTEMS_INVALID_SIZE;
+    }
+  }
 #endif
 #endif
 




More information about the vc mailing list