linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] copy_to_user check and whitespace cleanups in fs/cifs/file.c
@ 2004-12-26 23:24 Jesper Juhl
  2004-12-26 23:38 ` Alan Cox
  0 siblings, 1 reply; 17+ messages in thread
From: Jesper Juhl @ 2004-12-26 23:24 UTC (permalink / raw)
  To: Steve French, Steve French; +Cc: samba-technical, linux-kernel


Hi,

Patch below adds a check for the copy_to_user return value and makes a few 
whitespace cleanups in  fs/cifs/file.c::cifs_user_read()
I hope bundling two different things together in one patch is OK when the 
change is as small as this, but if you want it spplit in two patches, then 
just say so.


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.10-orig/fs/cifs/file.c linux-2.6.10/fs/cifs/file.c
--- linux-2.6.10-orig/fs/cifs/file.c	2004-12-24 22:33:48.000000000 +0100
+++ linux-2.6.10/fs/cifs/file.c	2004-12-27 00:18:35.000000000 +0100
@@ -1141,20 +1141,21 @@ cifs_user_read(struct file * file, char 
 	}
 	open_file = (struct cifsFileInfo *)file->private_data;
 
-	if((file->f_flags & O_ACCMODE) == O_WRONLY) {
-		cFYI(1,("attempting read on write only file instance"));
+	if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
+		cFYI(1, ("attempting read on write only file instance"));
 	}
 
-	for (total_read = 0,current_offset=read_data; read_size > total_read;
-				total_read += bytes_read,current_offset+=bytes_read) {
-		current_read_size = min_t(const int,read_size - total_read,cifs_sb->rsize);
+	for (total_read = 0, current_offset = read_data; read_size > total_read;
+			total_read += bytes_read, current_offset += bytes_read) {
+		current_read_size = min_t(const int, read_size - total_read, 
+			cifs_sb->rsize);
 		rc = -EAGAIN;
 		smb_read_data = NULL;
-		while(rc == -EAGAIN) {
+		while (rc == -EAGAIN) {
 			if ((open_file->invalidHandle) && (!open_file->closePend)) {
 				rc = cifs_reopen_file(file->f_dentry->d_inode,
 					file,TRUE);
-				if(rc != 0)
+				if (rc != 0)
 					break;
 			}
 
@@ -1164,9 +1165,13 @@ cifs_user_read(struct file * file, char 
 				 &bytes_read, &smb_read_data);
 
 			pSMBr = (struct smb_com_read_rsp *)smb_read_data;
-			copy_to_user(current_offset,smb_read_data + 4/* RFC1001 hdr*/
-				+ le16_to_cpu(pSMBr->DataOffset), bytes_read);
-			if(smb_read_data) {
+			if (copy_to_user(current_offset,smb_read_data + 4 /* RFC1001 hdr*/
+					+ le16_to_cpu(pSMBr->DataOffset), bytes_read)) {
+				FreeXid(xid);
+				return -EFAULT;
+			}
+				
+			if (smb_read_data) {
 				cifs_buf_release(smb_read_data);
 				smb_read_data = NULL;
 			}




Please keep me on CC.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2005-01-03 12:02 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-26 23:24 [patch] copy_to_user check and whitespace cleanups in fs/cifs/file.c Jesper Juhl
2004-12-26 23:38 ` Alan Cox
2004-12-27  1:21   ` Jesper Juhl
2004-12-28 23:48   ` [patch 1/3] copy_to_user check " Jesper Juhl
2004-12-28 22:45     ` Alan Cox
2004-12-28 23:52   ` [patch 2/3] whitespace cleanups " Jesper Juhl
2004-12-29  1:57     ` Jörn Engel
2004-12-29  2:59       ` Jesper Juhl
2004-12-29 12:29         ` Jörn Engel
2004-12-29 18:48           ` Domen Puncer
2004-12-29 13:42         ` [patch 2/3] " Horst von Brand
2004-12-29 14:48           ` Jörn Engel
2004-12-29 16:31             ` Horst von Brand
2004-12-29  9:51       ` Wichert Akkerman
2004-12-29 12:10         ` Jörn Engel
2005-01-03 12:01         ` Martin Waitz
2004-12-28 23:55   ` [patch 3/3] get rid of two unnessesary assignments " Jesper Juhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).