提交 008fa866 编写于 作者: O openharmony_ci 提交者: Gitee

!337 fix: fatfs memory leak

Merge pull request !337 from jianjian/master
...@@ -576,7 +576,7 @@ int fatfs_open(struct file *filep) ...@@ -576,7 +576,7 @@ int fatfs_open(struct file *filep)
ret = lock_fs(fs); ret = lock_fs(fs);
if (ret == FALSE) { if (ret == FALSE) {
ret = EBUSY; ret = EBUSY;
goto ERROR_EXIT; goto ERROR_FREE;
} }
fp->dir_sect = dp->sect; fp->dir_sect = dp->sect;
...@@ -595,7 +595,7 @@ int fatfs_open(struct file *filep) ...@@ -595,7 +595,7 @@ int fatfs_open(struct file *filep)
fp->buf = (BYTE*) ff_memalloc(SS(fs)); fp->buf = (BYTE*) ff_memalloc(SS(fs));
if (fp->buf == NULL) { if (fp->buf == NULL) {
ret = ENOMEM; ret = ENOMEM;
goto ERROR_FREE; goto ERROR_UNLOCK;
} }
LOS_ListAdd(&finfo->fp_list, &fp->fp_entry); LOS_ListAdd(&finfo->fp_list, &fp->fp_entry);
unlock_fs(fs, FR_OK); unlock_fs(fs, FR_OK);
...@@ -603,8 +603,9 @@ int fatfs_open(struct file *filep) ...@@ -603,8 +603,9 @@ int fatfs_open(struct file *filep)
filep->f_priv = fp; filep->f_priv = fp;
return fatfs_sync(vp->originMount->mountFlags, fs); return fatfs_sync(vp->originMount->mountFlags, fs);
ERROR_FREE: ERROR_UNLOCK:
unlock_fs(fs, FR_OK); unlock_fs(fs, FR_OK);
ERROR_FREE:
free(fp); free(fp);
ERROR_EXIT: ERROR_EXIT:
return -ret; return -ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册