Skip to content

Commit

Permalink
cifs: when renaming don't try to unlink negative dentry
Browse files Browse the repository at this point in the history
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 <jlayton@redhat.com>
Tested-by: Shirish Pargaonkar <shirishp@us.ibm.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Jeff Layton authored and Steve French committed Apr 17, 2009
1 parent 22c9d52 commit fc6f394
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/cifs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fc6f394

Please sign in to comment.