Messages in this thread Patch in this message | | | Date | Sun, 13 Feb 2005 16:44:41 +0100 | From | Luca <> | Subject | [PATCH 2.6] Check return of copy_from_user value in cifssmb.c [Re: Linux 2.6.11-rc4] |
| |
Linus Torvalds <torvalds@osdl.org> ha scritto: > this is hopefully the last -rc kernel before the real 2.6.11, so please > give it a whirl, and complain loudly about anything broken.
The following patch against 2.6.11-rc4 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@kronoz.cjb.net>
--- 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 Il dottore mi ha detto di smettere di fare cene intime per quattro. A meno che non ci siamo altre tre persone. - 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/
| |