[PATCH][re-send] check copy_to_user() return value in raw1394

From: Jesper Juhl
Date: Sun Nov 28 2004 - 12:25:56 EST



This patch makes sure we check the return value of copy_to_user() in
drivers/ieee1394/raw1394.c::raw1394_read() with the added bonus of
silencing this warning:
include/asm/uaccess.h: In function `raw1394_read':
drivers/ieee1394/raw1394.c:446: warning: ignoring return value of `__copy_to_user', declared with attribute warn_unused_result

I've submitted this before, but never got an ACK or NACK, and the patch is
still relevant against latest Linus bk (2.6.10-rc2-bk11 atm).


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

diff -up linux-2.6.10-rc2-bk11-orig/drivers/ieee1394/raw1394.c linux-2.6.10-rc2-bk11/drivers/ieee1394/raw1394.c
--- linux-2.6.10-rc2-bk11-orig/drivers/ieee1394/raw1394.c 2004-10-18 23:53:06.000000000 +0200
+++ linux-2.6.10-rc2-bk11/drivers/ieee1394/raw1394.c 2004-11-28 18:08:49.000000000 +0100
@@ -411,6 +411,7 @@ static ssize_t raw1394_read(struct file
struct file_info *fi = (struct file_info *)file->private_data;
struct list_head *lh;
struct pending_request *req;
+ ssize_t ret;

if (count != sizeof(struct raw1394_request)) {
return -EINVAL;
@@ -443,10 +444,15 @@ static ssize_t raw1394_read(struct file
req->req.error = RAW1394_ERROR_MEMFAULT;
}
}
- __copy_to_user(buffer, &req->req, sizeof(req->req));
+ if (copy_to_user(buffer, &req->req, sizeof(req->req))) {
+ ret = -EFAULT;
+ goto out;
+ }

+ ret = (ssize_t)sizeof(struct raw1394_request);
+out:
free_pending_request(req);
- return sizeof(struct raw1394_request);
+ return ret;
}




--
Jesper Juhl <juhl-lkml@xxxxxx>
Please CC me on replies from linux1394-devel, I'm not subscribed there.


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