diff --git a/fs/yaffs2/yaffs_vfs.c b/fs/yaffs2/yaffs_vfs.c index 8e8c55b605a..4dd618f8732 100644 --- a/fs/yaffs2/yaffs_vfs.c +++ b/fs/yaffs2/yaffs_vfs.c @@ -497,8 +497,16 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry, if (ret_val == YAFFS_OK) { if (target) { - drop_nlink(new_dentry->d_inode); - mark_inode_dirty(new_dentry->d_inode); + /* + * We have identified target to be a + * valid directory earlier. If it is + * not the case throw a warning. + */ + WARN_ON(!new_dentry->d_inode); + if (new_dentry->d_inode) { + drop_nlink(new_dentry->d_inode); + mark_inode_dirty(new_dentry->d_inode); + } } update_dir_time(old_dir);