From 547f8e7aaaf57516749636dc884401838eae439a Mon Sep 17 00:00:00 2001 From: Billy Kozak Date: Mon, 20 Jul 2015 10:18:02 -0600 Subject: [PATCH] Fixed race condition with rf cpu in read_frame Fixed a race condition that could occur in read_frame because the dataEntry is set to PENDING before we are finished reading from it. --- cpu/cc26xx/dev/cc26xx-rf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpu/cc26xx/dev/cc26xx-rf.c b/cpu/cc26xx/dev/cc26xx-rf.c index ea12aa0d3..b26771a8a 100644 --- a/cpu/cc26xx/dev/cc26xx-rf.c +++ b/cpu/cc26xx/dev/cc26xx-rf.c @@ -1334,8 +1334,6 @@ read_frame(void *buf, unsigned short buf_len) int len = 0; if(GET_FIELD_V(rx_read_entry, dataEntry, status) == DATA_ENTRY_STATUS_FINISHED) { - /* Set status to 0 "Pending" in element */ - GET_FIELD_V(rx_read_entry, dataEntry, status) = DATA_ENTRY_STATUS_PENDING; if(rx_read_entry[8] > 0) { memcpy(buf, (char *)&rx_read_entry[9], buf_len); @@ -1352,6 +1350,9 @@ read_frame(void *buf, unsigned short buf_len) rx_read_entry[8] = 0; } + /* Set status to 0 "Pending" in element */ + GET_FIELD_V(rx_read_entry, dataEntry, status) = DATA_ENTRY_STATUS_PENDING; + /* Move read entry pointer to next entry */ rx_read_entry = GET_FIELD_V(rx_read_entry, dataEntry, pNextEntry); }