This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d83ab55e00 fs/partition/txtable: Fix panic when no txtable was found
in last eraseblock
d83ab55e00 is described below
commit d83ab55e00e6269ffd50c146594e4812075b696b
Author: wangjianyu3 <[email protected]>
AuthorDate: Tue Nov 26 12:45:53 2024 +0800
fs/partition/txtable: Fix panic when no txtable was found in last eraseblock
Panic occured if no txtable was found in last eraseblock of MTD device and
`CONFIG_TXTABLE_DEFAULT_PARTITION` was disabled
Backtrace
sched_dumpstack
/workspace/nuttx/libs/libc/sched/sched_dumpstack.c:71
dump_assert_info
/workspace/nuttx/sched/misc/assert.c:718
xtensa_user_panic
/workspace/nuttx/arch/xtensa/src/common/xtensa_assert.c:188
(discriminator 1)
xtensa_user
??:?
_xtensa_user_handler
/workspace/nuttx/arch/xtensa/src/common/xtensa_user_handler.S:194
??
??:0
parse_txtable_partition
/workspace/nuttx/fs/partition/fs_txtable.c:136
parse_partition
/workspace/nuttx/fs/partition/fs_partition.c:165
parse_mtd_partition
/workspace/nuttx/fs/partition/fs_partition.c:291
Signed-off-by: wangjianyu3 <[email protected]>
---
fs/partition/fs_txtable.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/partition/fs_txtable.c b/fs/partition/fs_txtable.c
index 2e0dabcecd..fdba147d50 100644
--- a/fs/partition/fs_txtable.c
+++ b/fs/partition/fs_txtable.c
@@ -133,7 +133,8 @@ int parse_txtable_partition(FAR struct partition_state_s
*state,
/* Parsing data of partition table */
token = strtok_r(token, "\n", &save_ptr);
- if (strncmp(token, TXTABLE_MAGIC, strlen(TXTABLE_MAGIC)) != 0)
+ if (token == NULL ||
+ strncmp(token, TXTABLE_MAGIC, strlen(TXTABLE_MAGIC)) != 0)
{
save_ptr = NULL;
ret = -EFTYPE;