[PATCH] don't ignore copy_to_user return value insound/core/seq/seq_clientmgr.c::snd_seq_read

From: Jesper Juhl
Date: Tue Sep 07 2004 - 14:51:47 EST



Here's a patch that ensures the copy_to_user() return value gets checked
and acted upon if it is != 0 (that is, if we failed to copy all data) in
snd_seq_read().

Apart from being the right thing to do it also nicely gets rid of this
warning with gcc 3.4.0 :
sound/core/seq/seq_clientmgr.c: In function `snd_seq_read':
sound/core/seq/seq_clientmgr.c:423: warning: ignoring return value of `copy_to_user', declared with attribute warn_unused_result


Signed-off-by: Jesper Juhl <juhl-lkml@xxxxxx>

diff -up linux-2.6.9-rc1-bk13-orig/sound/core/seq/seq_clientmgr.c linux-2.6.9-rc1-bk13/sound/core/seq/seq_clientmgr.c
--- linux-2.6.9-rc1-bk13-orig/sound/core/seq/seq_clientmgr.c 2004-09-06 21:13:20.000000000 +0200
+++ linux-2.6.9-rc1-bk13/sound/core/seq/seq_clientmgr.c 2004-09-07 21:16:27.000000000 +0200
@@ -420,7 +420,10 @@ static ssize_t snd_seq_read(struct file
count -= err;
buf += err;
} else {
- copy_to_user(buf, &cell->event, sizeof(snd_seq_event_t));
+ if (copy_to_user(buf, &cell->event, sizeof(snd_seq_event_t))) {
+ err = -EFAULT;
+ break;
+ }
count -= sizeof(snd_seq_event_t);
buf += sizeof(snd_seq_event_t);
}


-
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/