subsys/fs: Fix fs_close on closed file causing NULL dereference
If fs_close gets invoked on closed file (e.g. double close) it would cause NULL dereference and system crash. Instead now it will just return with success, as the file is already closed anyway. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
ce426f69f0
commit
54492c2748
1 changed files with 4 additions and 0 deletions
|
@ -109,6 +109,10 @@ int fs_close(struct fs_file_t *zfp)
|
|||
{
|
||||
int rc = -EINVAL;
|
||||
|
||||
if (zfp->mp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (zfp->mp->fs->close != NULL) {
|
||||
rc = zfp->mp->fs->close(zfp);
|
||||
if (rc < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue