diff options
author | Jiri Slaby <jslaby@suse.cz> | 2010-11-01 11:08:55 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-11-01 23:47:21 -0400 |
commit | 50ae28f0144a790fc63a5b89b9aca3ffa9f88522 (patch) | |
tree | b0e77798ad82428f4f0026cf8f72cc0608ab3223 /fs/cifs/file.c | |
parent | c8ddb2713c624f432fa5fe3c7ecffcdda46ea0d4 (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>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 25 |
1 files changed, 11 insertions, 14 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, | |||
956 | ssize_t cifs_user_write(struct file *file, const char __user *write_data, | 956 | ssize_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 | } |