fixed deadlock in event groups when a mutex is used for memory allocation (#284)

Co-authored-by: Clemens Kresser <clemens.kresser@gmail.com>
Co-authored-by: Joseph Julicher <jjulicher@mac.com>
diff --git a/event_groups.c b/event_groups.c
index 9abfada..b486453 100644
--- a/event_groups.c
+++ b/event_groups.c
@@ -645,29 +645,29 @@
             configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );

             vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );

         }

-

-        #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )

-            {

-                /* The event group can only have been allocated dynamically - free

-                 * it again. */

-                vPortFree( pxEventBits );

-            }

-        #elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )

-            {

-                /* The event group could have been allocated statically or

-                 * dynamically, so check before attempting to free the memory. */

-                if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )

-                {

-                    vPortFree( pxEventBits );

-                }

-                else

-                {

-                    mtCOVERAGE_TEST_MARKER();

-                }

-            }

-        #endif /* configSUPPORT_DYNAMIC_ALLOCATION */

     }

     ( void ) xTaskResumeAll();

+

+    #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )

+        {

+            /* The event group can only have been allocated dynamically - free

+             * it again. */

+            vPortFree( pxEventBits );

+        }

+    #elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )

+        {

+            /* The event group could have been allocated statically or

+             * dynamically, so check before attempting to free the memory. */

+            if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )

+            {

+                vPortFree( pxEventBits );

+            }

+            else

+            {

+                mtCOVERAGE_TEST_MARKER();

+            }

+        }

+    #endif /* configSUPPORT_DYNAMIC_ALLOCATION */

 }

 /*-----------------------------------------------------------*/