[PATCH] pcmcia: handle __copy_from_user in ioctl

Dominik Brodowski linux at dominikbrodowski.net
Sun Nov 19 11:22:57 EST 2006


Hi,

On Fri, Nov 17, 2006 at 09:54:01PM -0800, Randy Dunlap wrote:
> From: Randy Dunlap <randy.dunlap at oracle.com>
> 
> Handle __copy_from_user() return value.
> 
> drivers/pcmcia/pcmcia_ioctl.c:597: warning: ignoring return value of '__copy_from_user', declared with attribute warn_unused_result

Thanks for noticing and fixing this. However, it introduced a small
memory leak (buf wasn't freed) -- therefore, I've applied this patch
to pcmcia-fixes-2.6 instead:

From: Dominik Brodowski <linux at dominikbrodowski.net>
Date: Sun, 19 Nov 2006 11:21:27 -0500
Subject: [PATCH] pcmcia: handle __copy_from_user() return value in ioctl

Handle __copy_from_user() return value.

drivers/pcmcia/pcmcia_ioctl.c:597: warning: ignoring return value of '__copy_from_user', declared with attribute warn_unused_result

Noticed and first fix by Randy Dunlap.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
---
 drivers/pcmcia/pcmcia_ioctl.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 310ede5..6383a39 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -594,7 +594,12 @@ static int ds_ioctl(struct inode * inode
 
     err = ret = 0;
 
-    if (cmd & IOC_IN) __copy_from_user((char *)buf, uarg, size);
+    if (cmd & IOC_IN) {
+	if (__copy_from_user((char *)buf, uarg, size)) {
+	    ret = -EFAULT;
+	    goto free_out;
+	}
+    }
 
     switch (cmd) {
     case DS_ADJUST_RESOURCE_INFO:
-- 
1.4.4




More information about the linux-pcmcia mailing list