blk/mtdoutstream: should flush before free

to avoid losing the data in the buffer

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen 2025-01-09 22:33:11 +08:00 committed by Donny(董九柱)
parent 379f246625
commit 95cf3b3aa9
3 changed files with 18 additions and 18 deletions

View file

@ -239,18 +239,18 @@ void lib_blkoutstream_close(FAR struct lib_blkoutstream_s *stream)
{
if (stream != NULL)
{
if (stream->inode != NULL)
{
close_blockdriver(stream->inode);
stream->inode = NULL;
}
if (stream->cache != NULL)
{
blkoutstream_flush(&stream->common);
lib_free(stream->cache);
stream->cache = NULL;
}
if (stream->inode != NULL)
{
close_blockdriver(stream->inode);
stream->inode = NULL;
}
}
}

View file

@ -267,18 +267,18 @@ void lib_mtdoutstream_close(FAR struct lib_mtdoutstream_s *stream)
{
if (stream != NULL)
{
if (stream->inode != NULL)
{
close_mtddriver(stream->inode);
stream->inode = NULL;
}
if (stream->cache != NULL)
{
mtdoutstream_flush(&stream->common);
lib_free(stream->cache);
stream->cache = NULL;
}
if (stream->inode != NULL)
{
close_mtddriver(stream->inode);
stream->inode = NULL;
}
}
}

View file

@ -277,18 +277,18 @@ void lib_mtdsostream_close(FAR struct lib_mtdsostream_s *stream)
{
if (stream != NULL)
{
if (stream->inode != NULL)
{
close_mtddriver(stream->inode);
stream->inode = NULL;
}
if (stream->cache != NULL)
{
mtdsostream_flush(&stream->common);
lib_free(stream->cache);
stream->cache = NULL;
}
if (stream->inode != NULL)
{
close_mtddriver(stream->inode);
stream->inode = NULL;
}
}
}