Fix memory leak when CONFIG_SMARTFS_USE_SECTOR_BUFFER is enabled
authorpradeep.ns <pradeep.ns@samsung.com>
Mon, 4 Sep 2017 17:47:40 +0000 (23:17 +0530)
committerpradeep.ns <pradeep.ns@samsung.com>
Mon, 4 Sep 2017 17:58:36 +0000 (23:28 +0530)
During error case in smartfs_open() , sf->buffer is not freed.

Signed-off-by: pradeep.ns <pradeep.ns@samsung.com>
os/fs/smartfs/smartfs_smart.c

index f84926c..70c483c 100644 (file)
@@ -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 */