lkml.org 
[lkml]   [2004]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] copy_to_user check and whitespace cleanups in fs/cifs/file.c

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.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:09    [W:0.073 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site