[PATCH] act upon copy_to_user failing and silence warning

From: Jesper Juhl
Date: Tue Dec 21 2004 - 17:54:04 EST



Hi,

patch below silences these two warnings :

drivers/isdn/hisax/config.c:636: warning: ignoring return value of `copy_to_user', declared with attribute warn_unused_result
drivers/isdn/hisax/config.c:647: warning: ignoring return value of `copy_to_user', declared with attribute warn_unused_result

by checking the return value of copy_to_user and returning -EFAULT if it
fails.

note: I don't have the hardware to actually test this, so all I've done is
tried to convince myself that this is correct by reading the code and then
compile test it.

Please review and consider applying.


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

diff -up linux-2.6.10-rc3-bk13-orig/drivers/isdn/hisax/config.c linux-2.6.10-rc3-bk13/drivers/isdn/hisax/config.c
--- linux-2.6.10-rc3-bk13-orig/drivers/isdn/hisax/config.c 2004-12-06 22:24:29.000000000 +0100
+++ linux-2.6.10-rc3-bk13/drivers/isdn/hisax/config.c 2004-12-21 23:55:00.000000000 +0100
@@ -633,7 +633,8 @@ int HiSax_readstatus(u_char __user *buf,
count = cs->status_end - cs->status_read + 1;
if (count >= len)
count = len;
- copy_to_user(p, cs->status_read, count);
+ if (copy_to_user(p, cs->status_read, count))
+ return -EFAULT;
cs->status_read += count;
if (cs->status_read > cs->status_end)
cs->status_read = cs->status_buf;
@@ -644,7 +645,8 @@ int HiSax_readstatus(u_char __user *buf,
cnt = HISAX_STATUS_BUFSIZE;
else
cnt = count;
- copy_to_user(p, cs->status_read, cnt);
+ if (copy_to_user(p, cs->status_read, cnt))
+ return -EFAULT;
p += cnt;
cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
count -= cnt;



PS. please kee me on CC if replies go only to lists other than LKML.


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