copy_to_user

Nilesh Tayade nilesh.tayade at netscout.com
Fri Dec 24 02:59:20 EST 2010


Hi,

On Fri, 2010-12-24 at 11:37 +0530, Hemanth Kumar wrote:

>                 
>                 > >
>                 
>         The mutex initialization is missing. 
>         Adding  mutex_init(&timer); in the driver init will make it
>         work.
>         
>         Thanks,
>         Mukti
>         
>         
>         Hi All,
>         
>             Can anybody please share some idea ,why I am getting
>         segmentation fault & kernel oops,
>         
>         Regards,
> 

I tried it, and it seems adding mutex_init() works as Mukti mentioned. I
did get a kernel oops before (but no segfault). After adding
mutex_init() there is no oops/segfault. The code, however, is reading
the garbage, that needs to be fixed.

pun-nilesht-dt0:/home/nilesh/Documents/handson # !mknod
mknod /dev/mytimer c 300 0

pun-nilesht-dt0:/home/nilesh/Documents # dmesg 
[ 2193.684735] Register timer maj = 300

pun-nilesht-dt0:/home/nilesh/Documents/handson # ./my_app.o 
 a = -30048 
 b = -23975 
 c = 32582 
...

See the attachments in case something is missing the code.

> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


-- 
Thanks,
Nilesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: my_drv.c
Type: text/x-csrc
Size: 1799 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20101224/a8ecc427/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: my_app.c
Type: text/x-csrc
Size: 560 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20101224/a8ecc427/attachment-0001.bin 


More information about the Kernelnewbies mailing list