[PATCH 2.6] Check return of copy_from_user value in cifssmb.c

From: Luca
Date: Thu Feb 03 2005 - 12:44:41 EST


Hello,
the following patch against 2.6.11-rc3 fixes this compile time warning:

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

It also fixes the strange indentation of the code in that point. Also
note that pSMB cannot be NULL, since the return value of smb_init (which
initiliaze pSMB) is checked (see line 874).

Signed-off-by: Luca Tettamanti <kronoz@xxxxxxxxxxxxxx>

--- a/fs/cifs/cifssmb.c 2005-02-03 17:43:18.000000000 +0100
+++ b/fs/cifs/cifssmb.c 2005-02-03 17:47:29.000000000 +0100
@@ -896,14 +896,17 @@
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 {
- /* No buffer */
- if(pSMB)
+
+ if(buf)
+ memcpy(pSMB->Data, buf, bytes_sent);
+ else if(ubuf) {
+ if (copy_from_user(pSMB->Data, ubuf, bytes_sent)) {
cifs_buf_release(pSMB);
+ return -EFAULT;
+ }
+ } else {
+ /* No buffer */
+ cifs_buf_release(pSMB);
return -EINVAL;
}


Luca
--
Home: http://kronoz.cjb.net
Un apostolo vedendo Gesu` camminare sulle acque:
- Cazzo se e` buono 'sto fumo!!!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/