linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6] Check return of copy_from_user value in cifssmb.c
@ 2005-02-03 17:30 Luca
  0 siblings, 0 replies; only message in thread
From: Luca @ 2005-02-03 17:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steve Frenchs, Linus Torvalds

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@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
Un apostolo vedendo Gesu` camminare sulle acque:
- Cazzo se e` buono 'sto fumo!!!

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-02-03 17:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-03 17:30 [PATCH 2.6] Check return of copy_from_user value in cifssmb.c Luca

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).