[linux-cifs-client] Re: [PATCH] in cifssmb.c add copy_from_user return value check and do minor formatting/whitespace cleanups.

Steven French sfrench at us.ibm.com
Thu Dec 23 04:54:03 GMT 2004


Thanks for sending this. 

I had already merged a copy_from_user rc check into the project bk tree 
(bk://cifs.bkbits.net/linux-2.5cifs) so it should get into the mm kernel 
next time it is refreshed.   I had been holidng off on the request to push 
it to mainline until after 2.6.10


Steve French
Senior Software Engineer
Linux Technology Center - IBM Austin
phone: 512-838-2294
email: sfrench at-sign us dot ibm dot com



Jesper Juhl <juhl-lkml at dif.dk> 
12/21/2004 05:33 PM

To
Steve French <sfrench at samba.org>, Steven French/Austin/IBM at IBMUS
cc
samba-technical at lists.samba.org, linux-kernel at vger.kernel.org
Subject
[PATCH] in cifssmb.c add copy_from_user return value check and do minor 
formatting/whitespace cleanups.







Hi, 

Seeing this warning :

fs/cifs/cifssmb.c:902: warning: ignoring return value of `copy_from_user', 
declared with attribute warn_unused_result

lead to the following patch.

The patch adds a check of the copy_from_user return value and returns 
-EFAULT if the call fails. In addition to that I did some 
formatting/whitespace changes - the code uses primarily tabs for 
indentation, but this little bit used spaces, so I changed that to tabs; I 

also added a few curly braces {} for a few if statements, in the same 
area, that seemed to be becomming quite hard to read without.

Patch has been compile tested, but I have no real way to test it properly 
beyond that. 
I hope the patch is acceptable and mergable :)

Btw, I'm only subscribed to LKML, so please keep me on CC.


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

diff -up linux-2.6.10-rc3-bk13-orig/fs/cifs/cifssmb.c 
linux-2.6.10-rc3-bk13/fs/cifs/cifssmb.c
--- linux-2.6.10-rc3-bk13-orig/fs/cifs/cifssmb.c 2004-12-20 
22:19:42.000000000 +0100
+++ linux-2.6.10-rc3-bk13/fs/cifs/cifssmb.c              2004-12-22 
00:21:38.000000000 +0100
@@ -895,14 +895,19 @@ CIFSSMBWrite(const int xid, struct cifsT
                                 bytes_sent = count;
                 pSMB->DataLengthHigh = 0;
                 pSMB->DataOffset =
-                    cpu_to_le16(offsetof(struct smb_com_write_req,Data) - 
4);
-    if(buf)
-                    memcpy(pSMB->Data,buf,bytes_sent);
-                else if(ubuf)
- copy_from_user(pSMB->Data,ubuf,bytes_sent);
-    else {
+                                cpu_to_le16(offsetof(struct 
smb_com_write_req,Data) - 4);
+
+                if (buf) {
+                                memcpy(pSMB->Data,buf,bytes_sent);
+                } else if (ubuf) {
+                                if 
(copy_from_user(pSMB->Data,ubuf,bytes_sent)) {
+                                                if (pSMB)
+ cifs_buf_release(pSMB);
+                                                return -EFAULT;
+                                }
+                } else {
                                 /* No buffer */
-                                if(pSMB)
+                                if (pSMB)
                                                 cifs_buf_release(pSMB);
                                 return -EINVAL;
                 }




-------------- next part --------------
HTML attachment scrubbed and removed


More information about the linux-cifs-client mailing list