smart: fix wrong freeing of device structure and use-after-free issues on error paths

This commit is contained in:
Jussi Kivilinna
2017-06-28 07:20:07 -06:00
committed by Gregory Nutt
parent 3b0c422743
commit 4eaa136850
2 changed files with 38 additions and 21 deletions
+2 -2
View File
@@ -791,7 +791,7 @@ static ssize_t smartfs_write(FAR struct file *filep, const char *buffer,
ret = FS_IOCTL(fs, BIOC_WRITESECT, (unsigned long) &readwrite);
if (ret < 0)
{
ferr("ERROR: Error %d writing sector %d data\n",
ferr("ERROR: Error %d writing sector %d data\n",
ret, sf->currsector);
goto errout_with_semaphore;
}
@@ -1587,8 +1587,8 @@ static int smartfs_bind(FAR struct inode *blkdriver, const void *data,
ret = smartfs_mount(fs, true);
if (ret != 0)
{
kmm_free(fs);
smartfs_semgive(fs);
kmm_free(fs);
return ret;
}