mirror of
https://github.com/apache/nuttx.git
synced 2025-12-09 03:33:51 +08:00
fs/inode: Fix inoderemove when removing an inode without parent
This modification ensures that inoderemove will error instead of trying to remove an inode without parent. This fix was implement by Richard Jiayang Liu. Signed-off-by: Richard Jiayang Liu <rjliu3@illinois.edu>
This commit is contained in:
committed by
Xiang Xiao
parent
6bcb8965cf
commit
f113d13cbf
@@ -92,7 +92,16 @@ static FAR struct inode *inode_unlink(FAR const char *path)
|
||||
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(desc.parent != NULL);
|
||||
/* The parent could be null if we are trying to remove the
|
||||
* root inode. In that case, fail because we cannot remove it.
|
||||
*/
|
||||
|
||||
if (desc.parent == NULL)
|
||||
{
|
||||
inode = NULL;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
desc.parent->i_child = inode->i_peer;
|
||||
}
|
||||
|
||||
@@ -101,6 +110,7 @@ static FAR struct inode *inode_unlink(FAR const char *path)
|
||||
atomic_fetch_sub(&inode->i_crefs, 1);
|
||||
}
|
||||
|
||||
errout:
|
||||
RELEASE_SEARCH(&desc);
|
||||
return inode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user