You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by vi...@apache.org on 2025/04/16 20:55:27 UTC
(mynewt-core) 01/01: sys/reboot_log: Fix crash on rotate
This is an automated email from the ASF dual-hosted git repository.
vipulrahane pushed a commit to branch vipul/reboot_log_rotate_bug_fix
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit b1e3b00858a675ddd4adf2f0073daafdcf6adea1
Author: Vipul Rahane <vi...@juul.com>
AuthorDate: Wed Apr 16 13:53:26 2025 -0700
sys/reboot_log: Fix crash on rotate
- Reboot was crash on rotate because the `l_arg` which points to the
`fcb_log` was actually getting set to the `fcb`, thereby causing a
crash. This fixes it.
---
sys/log/full/src/log_fcb.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/sys/log/full/src/log_fcb.c b/sys/log/full/src/log_fcb.c
index 9c7a02088..dd6b4ce15 100644
--- a/sys/log/full/src/log_fcb.c
+++ b/sys/log/full/src/log_fcb.c
@@ -914,6 +914,8 @@ log_fcb_copy_entry(struct log *log, struct fcb_entry *entry,
uint16_t hdr_len;
int dlen;
int rc;
+ struct fcb_log fcb_log_tmp = {0};
+ struct fcb_log *fcb_log_ptr;
struct fcb *fcb_tmp;
rc = log_fcb_read(log, entry, &ueh, 0, LOG_BASE_ENTRY_HDR_SIZE);
@@ -932,12 +934,22 @@ log_fcb_copy_entry(struct log *log, struct fcb_entry *entry,
goto err;
}
- /* Changing the fcb to be logged to be dst fcb */
+ /* Cache fcb_log pointer */
fcb_tmp = &((struct fcb_log *)log->l_arg)->fl_fcb;
+ fcb_log_ptr = (struct fcb_log *)log->l_arg;
- log->l_arg = dst_fcb;
+ /* Cache the fcb log, so that we preserve original fcb pointer and
+ * bookmark settings
+ */
+ memcpy(&fcb_log_tmp, log->l_arg, sizeof(struct fcb_log));
+ fcb_log_tmp.fl_fcb = *dst_fcb;
+ log->l_arg = &fcb_log_tmp;
rc = log_fcb_append(log, data, dlen);
- log->l_arg = fcb_tmp;
+
+ /* Restore the original fcb_log pointer */
+ log->l_arg = fcb_log_ptr;
+ ((struct fcb_log *)log->l_arg)->fl_fcb = *fcb_tmp;
+
if (rc) {
goto err;
}