lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-asf4-dfu/+/42321?usp=email )
Change subject: dfu: flash: protect parsing of rc of flashing ......................................................................
dfu: flash: protect parsing of rc of flashing
Otherwise it is not guaranteed that both dfu_status and dfu_state are in sync when the IRQ handler is running.
Change-Id: Ifc0d56d779ec31382855d6c367478104bc04e1e7 --- M usb_start.c 1 file changed, 2 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/21/42321/1
diff --git a/usb_start.c b/usb_start.c index cb2bc51..43b61b0 100644 --- a/usb_start.c +++ b/usb_start.c @@ -184,6 +184,7 @@ dfu_download_data, dfu_download_length); }
+ CRITICAL_SECTION_ENTER(); if (ERR_NONE == rc) { dfu_state = USB_DFU_STATE_DFU_DNLOAD_IDLE; // indicate flashing this block has been completed } else { // there has been a programming error @@ -196,6 +197,7 @@ dfu_status = USB_DFU_STATUS_ERR_PROG; } } + CRITICAL_SECTION_LEAVE(); } else { // there was no data to flash // this case should not happen, but it's not a critical error dfu_state = USB_DFU_STATE_DFU_DNLOAD_IDLE; // indicate flashing can continue