Hi, Thanks Abhinav and Danke. I found the issue:
Both of you are right, I wrongly allocate the memory. I never try to pass any string before (so pity) ... I am trapped in the equality of sizeof(int) and sizeof(*int). Different for pointer to char, the sizeof() must not be used, instead using length of string as parameter. Regards, DWI On 7/21/10, Danke Xie <[email protected]> wrote: > Hi Dwi, > > I couldn't really figure out what is being done in the code. But I > think I noticed a reason why the call might fail (though not 100% > sure). You allocated one byte with kmalloc, which is sizeof(char), but > you would be copying 4 bytes into the area, that is sizeof(tmp). I > think that's why you got a seg fault. Do you think so? > > Regards, > Danke > > On Jul 18, 7:39 pm, Dwi Sasongko Supriyadi <[email protected]> wrote: >> Hello, >> >> I tried to pass "string" parameter from user to kernel and the driver >> never get the parameter correctly. >> >> I have read following link as a reference: >> >> http://tldp.org/LDP/lkmpg/2.6/html/x892.html >> >> Then I modify get_user() with copy_from_user() as follow: >> >> char *tmp = kmalloc(sizeof(char), GFP_KERNEL); >> >> if (copy_from_user(tmp, (unsigned long *) param), sizeof (tmp)) { >> return -EFAULT; >> >> } >> >> It always failed to copy user data. Did I miss anything? >> >> In addition, I also tried it on embedded system to pass int and struct >> data types with success but passing string always failed (I use 2.6.28 >> kernel on MIPS 4KSd family). What is the constraint on passing >> parameter from user to kernel especially for "string" data type? Is it >> a must to pass it via write() file operations? >> >> I appreciate any comments or suggestions, Thanks in advance. >> >> Regards, >> DWI >> -- >> "A mathematician is a device for turning coffee into theorems." - Paul >> Erdos >> >> Contacts: >> +62 857 8038 8298 >> +62 813 9876 6576 >> >> Skype: dwi.sasongko >> GTalk: ruckuus > > -- > unsubscribe: [email protected] > website: http://groups.google.com/group/android-kernel -- "A mathematician is a device for turning coffee into theorems." - Paul Erdos Contacts: +62 857 8038 8298 +62 813 9876 6576 Skype: dwi.sasongko GTalk: ruckuus -- unsubscribe: [email protected] website: http://groups.google.com/group/android-kernel
