Fix bug written at the end of buffer

Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/54ee5ce9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/54ee5ce9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/54ee5ce9

Branch: refs/heads/develop
Commit: 54ee5ce9c94f6c2a729aedbbc370696a388bf51d
Parents: 3f6222c
Author: Fabio Utzig <[email protected]>
Authored: Tue Jan 3 23:12:58 2017 -0200
Committer: Fabio Utzig <[email protected]>
Committed: Fri Jan 20 07:27:40 2017 -0200

----------------------------------------------------------------------
 hw/drivers/flash/src/flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/54ee5ce9/hw/drivers/flash/src/flash.c
----------------------------------------------------------------------
diff --git a/hw/drivers/flash/src/flash.c b/hw/drivers/flash/src/flash.c
index 0ffa2cc..40e1706 100644
--- a/hw/drivers/flash/src/flash.c
+++ b/hw/drivers/flash/src/flash.c
@@ -405,7 +405,7 @@ flash_write(uint8_t flash_id, uint32_t addr, const void 
*buf, size_t len)
         /**
          * Write back extra stuff at the ending of page.
          */
-        if (len < PAGE_SIZE) {
+        if (bfa + len < PAGE_SIZE) {
             for (n = len; n < PAGE_SIZE; n++) {
                 hal_spi_tx_val(dev->spi_num, g_page_buffer[n]);
             }

Reply via email to