mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luca <kronos@kronoz.cjb.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org, Steve Frenchs <french@samba.org>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH 2.6] Check return value of copy_to_user in fs/cifs/file.c [Re: Linux 2.6.11-rc4]
Date: Sun, 13 Feb 2005 16:44:16 +0100	[thread overview]
Message-ID: <20050213154416.GA26396@dreamland.darkstar.lan> (raw)
In-Reply-To: <Pine.LNX.4.58.0502121928590.19649@ppc970.osdl.org>

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:

 CC [M]  fs/cifs/file.o
fs/cifs/file.c: In function `cifs_user_read':
fs/cifs/file.c:1168: warning: ignoring return value of
`copy_to_user', declared with attribute warn_unused_result

I also added an explicit check for errors other than -EAGAIN, since
CIFSSMBRead may return -ENOMEM if it's unable to allocate smb_com_read_rsp;
in that case we don't want to call copy_to_user with a NULL pointer.

Signed-off-by: Luca Tettamanti <kronoz@kronoz.cjb.net>

--- a/fs/cifs/file.c	2005-02-03 17:58:07.000000000 +0100
+++ b/fs/cifs/file.c	2005-02-03 18:17:37.000000000 +0100
@@ -1151,7 +1151,7 @@
 		current_read_size = min_t(const int,read_size - total_read,cifs_sb->rsize);
 		rc = -EAGAIN;
 		smb_read_data = NULL;
-		while(rc == -EAGAIN) {
+		while(1) {
 			if ((open_file->invalidHandle) && (!open_file->closePend)) {
 				rc = cifs_reopen_file(file->f_dentry->d_inode,
 					file,TRUE);
@@ -1164,13 +1164,22 @@
 				 current_read_size, *poffset,
 				 &bytes_read, &smb_read_data);
 
+			if (rc == -EAGAIN)
+				continue;
+			else
+				break;
+
 			pSMBr = (struct smb_com_read_rsp *)smb_read_data;
-			copy_to_user(current_offset,smb_read_data + 4/* RFC1001 hdr*/
+			rc = copy_to_user(current_offset,smb_read_data + 4/* RFC1001 hdr*/
 				+ le16_to_cpu(pSMBr->DataOffset), bytes_read);
 			if(smb_read_data) {
 				cifs_buf_release(smb_read_data);
 				smb_read_data = NULL;
 			}
+			if (rc) {
+				FreeXid(xid);
+				return -EFAULT;
+			}
 		}
 		if (rc || (bytes_read == 0)) {
 			if (total_read) {



Luca
-- 
Home: http://kronoz.cjb.net
Se non sei parte della soluzione, allora sei parte del problema.

  parent reply	other threads:[~2005-02-13 15:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-13  3:34 Linux 2.6.11-rc4 Linus Torvalds
2005-02-13 13:00 ` Enrico Bartky
2005-02-13 16:13   ` Jean Delvare
2005-02-13 13:28 ` Francois Romieu
2005-02-13 15:44 ` Luca [this message]
2005-02-13 17:28   ` [PATCH 2.6] Check return value of copy_to_user in fs/cifs/file.c [Re: Linux 2.6.11-rc4] Marcel Sebek
2005-02-13 20:22     ` Luca
2005-02-13 15:44 ` [PATCH 2.6] Check return of copy_from_user value in cifssmb.c " Luca
2005-02-14 18:12 ` Linux 2.6.11-rc4 (compile stats) John Cherry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050213154416.GA26396@dreamland.darkstar.lan \
    --to=kronos@kronoz.cjb.net \
    --cc=akpm@osdl.org \
    --cc=french@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®