From: Jeff Layton Date: Fri, 17 Apr 2009 15:45:30 +0000 (-0400) Subject: cifs: when renaming don't try to unlink negative dentry X-Git-Tag: firefly_0821_release~14416^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fc6f394332ef1bf6ff5fbeaba0f2cd7a3c7971b6;p=firefly-linux-kernel-4.4.55.git cifs: when renaming don't try to unlink negative dentry When attempting to rename a file on a read-only share, the kernel can call cifs_unlink on a negative dentry, which causes an oops. Only try to unlink the file if it's a positive dentry. Signed-off-by: Jeff Layton Tested-by: Shirish Pargaonkar CC: Stable Signed-off-by: Steve French --- diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 09082ac85185..f36b4e40e443 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -1453,7 +1453,8 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry, checking the UniqueId via FILE_INTERNAL_INFO */ unlink_target: - if ((rc == -EACCES) || (rc == -EEXIST)) { + /* Try unlinking the target dentry if it's not negative */ + if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST)) { tmprc = cifs_unlink(target_dir, target_dentry); if (tmprc) goto cifs_rename_exit;