Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 913

kernel-2.6.18-238.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Thu, 14 May 2009 12:10:43 -0400
Subject: [fs] cifs: renaming don't try to unlink negative dentry
Message-id: 1242317443-10443-1-git-send-email-jlayton@redhat.com
O-Subject: [RHEL5.4 PATCH] BZ#500839: cifs: when renaming don't try to unlink negative dentry
Bugzilla: 500839
RH-Acked-by: Josef Bacik <josef@redhat.com>

This bug was reported upstream recently and I think it's important that
we also fix this for 5.4.

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>

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 8518255..0512d9c 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -1461,7 +1461,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;