From 9a6fd91198cc1c28f6466160e35f0cb7fd1e7a4d Mon Sep 17 00:00:00 2001 From: "pradeep.ns" Date: Mon, 4 Sep 2017 23:17:40 +0530 Subject: [PATCH] Fix memory leak when CONFIG_SMARTFS_USE_SECTOR_BUFFER is enabled During error case in smartfs_open() , sf->buffer is not freed. Signed-off-by: pradeep.ns --- os/fs/smartfs/smartfs_smart.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/os/fs/smartfs/smartfs_smart.c b/os/fs/smartfs/smartfs_smart.c index f84926c..70c483c 100644 --- a/os/fs/smartfs/smartfs_smart.c +++ b/os/fs/smartfs/smartfs_smart.c @@ -345,6 +345,12 @@ static int smartfs_open(FAR struct file *filep, const char *relpath, int oflags, goto errout_with_semaphore; errout_with_buffer: +#ifdef CONFIG_SMARTFS_USE_SECTOR_BUFFER + if (sf->buffer != NULL) { + kmm_free(sf->buffer); + sf->buffer = NULL; + } +#endif if (sf->entry.name != NULL) { /* Free the space for the name too */ -- 2.7.4