Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
6db8c434
Commit
6db8c434
authored
Nov 04, 2021
by
Bernd Meyer
Committed by
Johny Mattsson
Nov 04, 2021
Browse files
Prevent memory leak in UART driver when message handling is slow
parent
5c59c57a
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/platform/platform.c
View file @
6db8c434
...
@@ -116,12 +116,6 @@ static void task_uart( void *pvParameters ){
...
@@ -116,12 +116,6 @@ static void task_uart( void *pvParameters ){
if
(
xQueueReceive
(
uart_status
[
id
].
queue
,
(
void
*
)
&
event
,
(
portTickType
)
portMAX_DELAY
))
{
if
(
xQueueReceive
(
uart_status
[
id
].
queue
,
(
void
*
)
&
event
,
(
portTickType
)
portMAX_DELAY
))
{
switch
(
event
.
type
)
{
switch
(
event
.
type
)
{
case
UART_DATA
:
{
case
UART_DATA
:
{
post
=
(
uart_event_post_t
*
)
malloc
(
sizeof
(
uart_event_post_t
));
if
(
post
==
NULL
)
{
ESP_LOGE
(
UART_TAG
,
"Can not alloc memory in task_uart()"
);
// reboot here?
continue
;
}
// Attempt to coalesce received bytes to reduce risk of overrunning
// Attempt to coalesce received bytes to reduce risk of overrunning
// the task event queue.
// the task event queue.
size_t
len
;
size_t
len
;
...
@@ -129,6 +123,13 @@ static void task_uart( void *pvParameters ){
...
@@ -129,6 +123,13 @@ static void task_uart( void *pvParameters ){
len
=
event
.
size
;
len
=
event
.
size
;
if
(
len
==
0
)
if
(
len
==
0
)
continue
;
// we already gobbled all the bytes
continue
;
// we already gobbled all the bytes
post
=
(
uart_event_post_t
*
)
malloc
(
sizeof
(
uart_event_post_t
));
if
(
post
==
NULL
)
{
ESP_LOGE
(
UART_TAG
,
"Can not alloc memory in task_uart()"
);
// reboot here?
continue
;
}
post
->
data
=
malloc
(
len
);
post
->
data
=
malloc
(
len
);
if
(
post
->
data
==
NULL
)
{
if
(
post
->
data
==
NULL
)
{
ESP_LOGE
(
UART_TAG
,
"Can not alloc memory in task_uart()"
);
ESP_LOGE
(
UART_TAG
,
"Can not alloc memory in task_uart()"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment