mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 03:03:37 +08:00
libc/blkoutstream: Zero the cache to avoid random data
and skip zero cache in lib_mtdoutstream_open since it's aleady done ih mtdoutstream_puts Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
@@ -104,6 +104,11 @@ static int blkoutstream_puts(FAR struct lib_outstream_s *self,
|
||||
}
|
||||
else if (remain < sectorsize)
|
||||
{
|
||||
/* Set content to all 0 before caching,
|
||||
* so no random content will be flushed
|
||||
*/
|
||||
|
||||
memset(stream->cache, 0, sectorsize);
|
||||
memcpy(stream->cache, ptr, remain);
|
||||
self->nput += remain;
|
||||
remain = 0;
|
||||
|
||||
@@ -295,7 +295,7 @@ int lib_mtdoutstream_open(FAR struct lib_mtdoutstream_s *stream,
|
||||
if (node->u.i_mtd->write == NULL)
|
||||
#endif
|
||||
{
|
||||
stream->cache = lib_zalloc(stream->geo.erasesize);
|
||||
stream->cache = lib_malloc(stream->geo.erasesize);
|
||||
if (stream->cache == NULL)
|
||||
{
|
||||
close_mtddriver(node);
|
||||
|
||||
Reference in New Issue
Block a user