Re: problems

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

 



Hi,

From what is visible in the code excerpt you added, you don't allocate any memory where the variable res points to.
If this is the reason, replacing 'char *res;' by 'char res[20];' or adding the line
'res = (char *) malloc(20;' will solve the problem.

Israel Fernandez wrote:

> Hi:
> I have a LKM with a /proc file to communicate a user land process with.
> this is the read function in my LKM:
> _____________________________________
> copy_to_user(buf, strBuf, len);
> put_user(0, &buf[len]);
> ...
> return len
>
> and this is what i do in the userland:
>
> int fd = open("/proc/my_proc", O_RDONLY);
> char *res;
> read(fd, res, 20);
> close(fd);
> _____________________________________
> it can read ok, but i get the following messages:
>
> 01913: symbol=exit;  lookup in file=/home/..././savld /*This is my user
> land proc*/
> 01913: symbol=exit;  lookup in file=/usr/lib/libstdc++-libc6.2-2.so.3
> ...
> lookup 0x080048000 0x00000238 -> 0x40092000 0x000e04f0 /1 close
> 01913: symbol=exit;  lookup in file=/home/..././savld /*This is my user
> land proc*/
> 01913: symbol=exit;  lookup in file=/usr/lib/libstdc++-libc6.2-2.so.3
> ...
> Segmentation Fault
>
> can somebody tell what's wrong?
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> IRC Channel:   irc.openprojects.net / #kernelnewbies
> Web Page:      http://www.kernelnewbies.org/

--
Supercomputing System AG          email: maletinsky@scs.ch
Martin Maletinsky                 phone: +41 (0)1 445 16 05
Technoparkstrasse 1               fax:   +41 (0)1 445 16 10
CH-8005 Zurich


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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