Skip to contentSkip to conversation

fix cifs_user_read oops when null SMB response on forcedirectio mount

PATCH New Steve French 1 participant 1 message Feb 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix cifs_user_read oops when null SMB response on forcedirectio mount

This patch fixes an oops reported by Adrian Bunk in cifs_user_read when a null read response is returned on a forcedirectio mount.

fs/cifs/file.c +0 -0
index d17c97d..675bd25 100644
@@ -1442,13 +1442,15 @@ ssize_t cifs_user_read(struct file *file
					 &bytes_read, &smb_read_data,
					 &buf_type);
			pSMBr = (struct smb_com_read_rsp *)smb_read_data;

- if (copy_to_user(current_offset, - smb_read_data + 4 /* RFC1001 hdr */
- + le16_to_cpu(pSMBr->DataOffset), - bytes_read)) {
- rc = -EFAULT;
- }

			if (smb_read_data) {

+ if (copy_to_user(current_offset,
+ smb_read_data +
+ 4 /* RFC1001 length field */ +
+ le16_to_cpu(pSMBr->DataOffset),
+ bytes_read)) {
+ rc = -EFAULT;
+ }
+

				if(buf_type == CIFS_SMALL_BUFFER)
					cifs_small_buf_release(smb_read_data);
				else if(buf_type == CIFS_LARGE_BUFFER)
fs/cifs/file.c +8 -6
index d17c97d..675bd25 100644
@@ -1442,13 +1442,15 @@ ssize_t cifs_user_read(struct file *file
 					 &bytes_read, &smb_read_data,
 					 &buf_type);
 			pSMBr = (struct smb_com_read_rsp *)smb_read_data;
-			if (copy_to_user(current_offset, 
-					 smb_read_data + 4 /* RFC1001 hdr */
-					 + le16_to_cpu(pSMBr->DataOffset), 
-					 bytes_read)) {
-				rc = -EFAULT;
-			}
 			if (smb_read_data) {
+				if (copy_to_user(current_offset,
+						smb_read_data +
+						4 /* RFC1001 length field */ +
+						le16_to_cpu(pSMBr->DataOffset),
+						bytes_read)) {
+					rc = -EFAULT;
+				}
+
 				if(buf_type == CIFS_SMALL_BUFFER)
 					cifs_small_buf_release(smb_read_data);
 				else if(buf_type == CIFS_LARGE_BUFFER)