EFAULT in an ioctl (in a kernel module) when calling copy_to_user() - why ??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I had written a very simple ioctl() method in a module;
this ioctl calls copy_to_user();

I am getting EFAULT when trying to call this ioctl from
use space.

Any idea what can be the reason ?

Here is the code:

static unsigned long my_ioctl(struct inode* inode,
				   		      struct file* file,
						      unsigned int cmd,
						      unsigned long data)
													
  {
	...
	...
case MY_IOCTL:
  {
  unsigned int result = 99;
			
  if (copy_to_user((unsigned int *)data,
				&result,
				sizeof(unsigned int)))
    {
   printk("copy_to_user failed\n");	
   return -EFAULT;
   }
			
}

Regards,
  John

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux