From: pradeep.ns Date: Mon, 4 Sep 2017 17:47:40 +0000 (+0530) Subject: Fix memory leak when CONFIG_SMARTFS_USE_SECTOR_BUFFER is enabled X-Git-Tag: 1.1_Public_Release~273^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a6fd91198cc1c28f6466160e35f0cb7fd1e7a4d;p=rtos%2Ftinyara.git 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 --- 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 */