noteram:read noteram may cause crash

noteram_get may cause _read = ni_bufsize cause assert crash

[ 1493.627200] [79] [ EMERG] [ap] _assert: Assertion failed : at file: note/noteram_driver.c:370 task: trace process: trace 0x446f238a
[ 1493.627400] [79] [ EMERG] [ap] backtrace:
[ 1493.627500] [79] [ EMERG] [ap] [79] [<0xf7933c9d>] _fini+0xae0720b9/0xb673e41b
[ 1493.628400] [79] [ EMERG] [ap] [79] [<0x498b1b0c>] host_backtrace+0x42/0x72
[ 1493.629300] [79] [ EMERG] [ap] [79] [<0x48bef3d1>] up_backtrace+0x127/0x2d2
[ 1493.630200] [79] [ EMERG] [ap] [79] [<0x48b86bed>] sched_backtrace+0x71/0x8a
[ 1493.631100] [79] [ EMERG] [ap] [79] [<0x44676273>] sched_dumpstack+0xed/0x486
[ 1493.631600] [79] [ EMERG] [ap] [79] [<0x445c61ff>] _assert+0x9f0/0xb38
[ 1493.632200] [79] [ EMERG] [ap] [79] [<0x4420dd07>] __assert+0x3f/0x4c
[ 1493.632800] [79] [ EMERG] [ap] [79] [<0x44151648>] noteram_get+0x1b0/0x5fe
[ 1493.633600] [79] [ EMERG] [ap] [79] [<0x44152370>] noteram_read+0x331/0x4f7
[ 1493.634200] [79] [ EMERG] [ap] [79] [<0x444c66f9>] file_read+0x38b/0x3c0
[ 1493.634700] [79] [ EMERG] [ap] [79] [<0x444c6840>] nx_read+0x112/0x170
[ 1493.635300] [79] [ EMERG] [ap] [79] [<0x444c68e5>] NXread+0x47/0xfa
[ 1493.635800] [79] [ EMERG] [ap] [79] [<0x446f2c70>] trace_dump+0x148/0x2f4
[ 1493.636400] [79] [ EMERG] [ap] [79] [<0x446f110b>] trace_cmd_dump+0x41b/0x4b9
[ 1493.636900] [79] [ EMERG] [ap] [79] [<0x446f2723>] trace_main+0x399/0x6e2
[ 1493.637500] [79] [ EMERG] [ap] [79] [<0x44217fc9>] nxtask_startup+0x69/0x7c
[ 1493.638000] [79] [ EMERG] [ap] [79] [<0x440f9b78>] nxtask_start+0x8a5/0x8b8

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
This commit is contained in:
dulibo1 2024-03-20 14:40:33 +08:00 committed by Xiang Xiao
parent 1c8d0bfdc7
commit 2f12e18297

View File

@ -365,7 +365,7 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
{
/* Skip the large note so that we do not get constipated. */
drv->ni_read = noteram_next(drv, read, notelen);
drv->ni_read = noteram_next(drv, read, NOTE_ALIGN(notelen));
/* and return an error */
@ -387,7 +387,7 @@ static ssize_t noteram_get(FAR struct noteram_driver_s *drv,
remaining--;
}
drv->ni_read = NOTE_ALIGN(read);
drv->ni_read = noteram_next(drv, drv->ni_read, NOTE_ALIGN(notelen));
return notelen;
}