Browse Source

修复低概率终端无法输入问题 (#6464)

* [ulog] Fix the problem that the terminal cannot input

* [mem] Fix NULL pointer access
Tangyuxin 2 years ago
parent
commit
ca30428cee
2 changed files with 5 additions and 10 deletions
  1. 0 4
      components/utilities/ulog/backend/console_be.c
  2. 5 6
      src/mem.c

+ 0 - 4
components/utilities/ulog/backend/console_be.c

@@ -31,11 +31,7 @@ void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level
     }
     }
     else
     else
     {
     {
-        rt_uint16_t old_flag = dev->open_flag;
-
-        dev->open_flag |= RT_DEVICE_FLAG_STREAM;
         rt_device_write(dev, 0, log, len);
         rt_device_write(dev, 0, log, len);
-        dev->open_flag = old_flag;
     }
     }
 #else
 #else
     rt_hw_console_output(log);
     rt_hw_console_output(log);

+ 5 - 6
src/mem.c

@@ -525,12 +525,6 @@ void rt_smem_free(void *rmem)
 
 
     /* Get the corresponding struct rt_small_mem_item ... */
     /* Get the corresponding struct rt_small_mem_item ... */
     mem = (struct rt_small_mem_item *)((rt_uint8_t *)rmem - SIZEOF_STRUCT_MEM);
     mem = (struct rt_small_mem_item *)((rt_uint8_t *)rmem - SIZEOF_STRUCT_MEM);
-
-    RT_DEBUG_LOG(RT_DEBUG_MEM,
-                 ("release memory 0x%x, size: %d\n",
-                  (rt_ubase_t)rmem,
-                  (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
-
     /* ... which has to be in a used state ... */
     /* ... which has to be in a used state ... */
     small_mem = MEM_POOL(mem);
     small_mem = MEM_POOL(mem);
     RT_ASSERT(small_mem != RT_NULL);
     RT_ASSERT(small_mem != RT_NULL);
@@ -541,6 +535,11 @@ void rt_smem_free(void *rmem)
               (rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end);
               (rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end);
     RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem);
     RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem);
 
 
+    RT_DEBUG_LOG(RT_DEBUG_MEM,
+                 ("release memory 0x%x, size: %d\n",
+                  (rt_ubase_t)rmem,
+                  (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr))));
+
     /* ... and is now unused. */
     /* ... and is now unused. */
     mem->pool_ptr = MEM_FREED();
     mem->pool_ptr = MEM_FREED();
 #ifdef RT_USING_MEMTRACE
 #ifdef RT_USING_MEMTRACE