Skip to content

Commit fc6f394

Browse files
jtlaytonSteve French
authored andcommitted
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 <[email protected]> Tested-by: Shirish Pargaonkar <[email protected]> CC: Stable <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 22c9d52 commit fc6f394

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/cifs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,8 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry,
14531453
checking the UniqueId via FILE_INTERNAL_INFO */
14541454

14551455
unlink_target:
1456-
if ((rc == -EACCES) || (rc == -EEXIST)) {
1456+
/* Try unlinking the target dentry if it's not negative */
1457+
if (target_dentry->d_inode && (rc == -EACCES || rc == -EEXIST)) {
14571458
tmprc = cifs_unlink(target_dir, target_dentry);
14581459
if (tmprc)
14591460
goto cifs_rename_exit;

0 commit comments

Comments
 (0)