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 <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>

authored by Jeff Layton and committed by Steve French fc6f3943 22c9d52b

+2 -1
+2 -1
fs/cifs/inode.c
··· 1453 1453 checking the UniqueId via FILE_INTERNAL_INFO */ 1454 1454 1455 1455 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)) { 1457 1458 tmprc = cifs_unlink(target_dir, target_dentry); 1458 1459 if (tmprc) 1459 1460 goto cifs_rename_exit;