aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2010-11-01 11:08:55 -0400
committerSteve French <sfrench@us.ibm.com>2010-11-01 23:47:21 -0400
commit50ae28f0144a790fc63a5b89b9aca3ffa9f88522 (patch)
treeb0e77798ad82428f4f0026cf8f72cc0608ab3223
parentc8ddb2713c624f432fa5fe3c7ecffcdda46ea0d4 (diff)
FS: cifs, remove unneeded NULL tests
Stanse found that pSMBFile in cifs_ioctl and file->f_path.dentry in cifs_user_write are dereferenced prior their test to NULL. The alternative is not to dereference them before the tests. The patch is to point out the problem, you have to decide. While at it we cache the inode in cifs_user_write to a local variable and use all over the function. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Steve French <sfrench@samba.org> Cc: linux-cifs@vger.kernel.org Cc: Jeff Layton <jlayton@redhat.com> Cc: Christoph Hellwig <hch@infradead.org> Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/file.c25
-rw-r--r--fs/cifs/ioctl.c4
2 files changed, 11 insertions, 18 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index ae82159cf7fa..5d06eb3078de 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -956,6 +956,7 @@ cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
956ssize_t cifs_user_write(struct file *file, const char __user *write_data, 956ssize_t cifs_user_write(struct file *file, const char __user *write_data,
957 size_t write_size, loff_t *poffset) 957 size_t write_size, loff_t *poffset)
958{ 958{
959 struct inode *inode = file->f_path.dentry->d_inode;
959 int rc = 0; 960 int rc = 0;
960 unsigned int bytes_written = 0; 961 unsigned int bytes_written = 0;
961 unsigned int total_written; 962 unsigned int total_written;
@@ -963,7 +964,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
963 struct cifsTconInfo *pTcon; 964 struct cifsTconInfo *pTcon;
964 int xid, long_op; 965 int xid, long_op;
965 struct cifsFileInfo *open_file; 966 struct cifsFileInfo *open_file;
966 struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); 967 struct cifsInodeInfo *cifsi = CIFS_I(inode);
967 968
968 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 969 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
969 970
@@ -1029,21 +1030,17 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
1029 1030
1030 cifs_stats_bytes_written(pTcon, total_written); 1031 cifs_stats_bytes_written(pTcon, total_written);
1031 1032
1032 /* since the write may have blocked check these pointers again */
1033 if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
1034 struct inode *inode = file->f_path.dentry->d_inode;
1035/* Do not update local mtime - server will set its actual value on write 1033/* Do not update local mtime - server will set its actual value on write
1036 * inode->i_ctime = inode->i_mtime = 1034 * inode->i_ctime = inode->i_mtime =
1037 * current_fs_time(inode->i_sb);*/ 1035 * current_fs_time(inode->i_sb);*/
1038 if (total_written > 0) { 1036 if (total_written > 0) {
1039 spin_lock(&inode->i_lock); 1037 spin_lock(&inode->i_lock);
1040 if (*poffset > file->f_path.dentry->d_inode->i_size) 1038 if (*poffset > inode->i_size)
1041 i_size_write(file->f_path.dentry->d_inode, 1039 i_size_write(inode, *poffset);
1042 *poffset); 1040 spin_unlock(&inode->i_lock);
1043 spin_unlock(&inode->i_lock);
1044 }
1045 mark_inode_dirty_sync(file->f_path.dentry->d_inode);
1046 } 1041 }
1042 mark_inode_dirty_sync(inode);
1043
1047 FreeXid(xid); 1044 FreeXid(xid);
1048 return total_written; 1045 return total_written;
1049} 1046}
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 077bf756f342..2fa22f20cfc5 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -63,8 +63,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
63#ifdef CONFIG_CIFS_POSIX 63#ifdef CONFIG_CIFS_POSIX
64 case FS_IOC_GETFLAGS: 64 case FS_IOC_GETFLAGS:
65 if (CIFS_UNIX_EXTATTR_CAP & caps) { 65 if (CIFS_UNIX_EXTATTR_CAP & caps) {
66 if (pSMBFile == NULL)
67 break;
68 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid, 66 rc = CIFSGetExtAttr(xid, tcon, pSMBFile->netfid,
69 &ExtAttrBits, &ExtAttrMask); 67 &ExtAttrBits, &ExtAttrMask);
70 if (rc == 0) 68 if (rc == 0)
@@ -80,8 +78,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
80 rc = -EFAULT; 78 rc = -EFAULT;
81 break; 79 break;
82 } 80 }
83 if (pSMBFile == NULL)
84 break;
85 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid, 81 /* rc= CIFSGetExtAttr(xid,tcon,pSMBFile->netfid,
86 extAttrBits, &ExtAttrMask);*/ 82 extAttrBits, &ExtAttrMask);*/
87 } 83 }