From e43aa99ae8751d3cfb845bd20ab491680b6b409c Mon Sep 17 00:00:00 2001 From: ChenChuang Date: Sun, 14 Apr 2024 14:59:41 +0800 Subject: [PATCH] fix: the bug about rwbuffer causing mem overflow when the offest from rwb->wrblockstart to startblock plus rwb->wrnblocks is greater than rwb->wralignblocks, it will be causing memory overflow since rwb->wrbuffer is allocated rwb.wrmaxblock(rwb.wralignblocks) blocks. --- drivers/misc/rwbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/rwbuffer.c b/drivers/misc/rwbuffer.c index 009756c1a0..8468b56132 100644 --- a/drivers/misc/rwbuffer.c +++ b/drivers/misc/rwbuffer.c @@ -819,7 +819,7 @@ int rwb_initialize(FAR struct rwbuffer_s *rwb) /* Allocate the write buffer */ - allocsize = rwb->wrmaxblocks * rwb->blocksize; + allocsize = rwb->wrmaxblocks * rwb->blocksize * 2; rwb->wrbuffer = kmm_malloc(allocsize); if (!rwb->wrbuffer) {