Discussion:
error while deallocating memory
kishore
2006-01-02 13:12:17 UTC
Permalink
hi all,

I am working on LiS-2.18.0 ( downloaded from gcom.com) .
My Redhat and kernel versions are,
Redhat Enterprise Linux WS release 4 ( Nahant Update 2) with kernel version
2.6.9-16.EL .

I am facing a severe problem while deallocating the memory.
The whole scenario is as follows :

I wrote a driver and merged it with streams.
In the driver, just i am allocating memory for ten number of structures in
pw_open( ) and deallocating in pw_close( ).

I did the following steps:

1. created a folder named "pw" /usr/src/LiS/pkg/
2. placed the Config, Makefile and pwmodule.o in /usr/src/LiS/pkg/pw/.
3. moved to /usr/src/LiS
4. make clean
5. make
6. make install
7. modprobe streams

When I am trying to unload streams using

8. rmmod streams
the system is going to hung.

The following lines are from /var/log/messages,

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

Jan 2 15:52:13 rhel4 kernel: Copyright (c) 1997-2004 David Grothe, et al,
http://www.gcom.com
Jan 2 15:52:13 rhel4 kernel: Major device number 254.
Jan 2 15:52:13 rhel4 kernel: Version 2.18.0r4 12/12/05. Compiled for kernel
version 2.6.9-16.EL.
Jan 2 15:52:13 rhel4 kernel: Using <linux/poll.h>
<LiS/include/sys/stropts.h>
Jan 2 15:52:13 rhel4 kernel: Kernel register args 3, LiS register args 0
Jan 2 15:52:13 rhel4 kernel:
==================================================================
Jan 2 15:52:13 rhel4 kernel: LiS-RunQ-2.18.0r4 running on CPU 0 pid=2685
Jan 2 15:52:14 rhel4 pam_timestamp_check: pam_timestamp: `/var/'
permissions are lax
Jan 2 15:52:19 rhel4 pam_timestamp_check: pam_timestamp: `/var/'
permissions are lax
Jan 2 15:52:22 rhel4 kernel: pwmodule_open
Jan 2 15:52:22 rhel4 kernel: p[0] success
Jan 2 15:52:22 rhel4 kernel: p[0]->ip success
Jan 2 15:52:22 rhel4 kernel: p[0]->cp success
Jan 2 15:52:22 rhel4 kernel: p[1] success
Jan 2 15:52:22 rhel4 kernel: p[1]->ip success
Jan 2 15:52:22 rhel4 kernel: p[1]->cp success
Jan 2 15:52:22 rhel4 kernel: p[2] success
Jan 2 15:52:22 rhel4 kernel: p[2]->ip success
Jan 2 15:52:22 rhel4 kernel: p[2]->cp success
Jan 2 15:52:22 rhel4 kernel: p[3] success
Jan 2 15:52:22 rhel4 kernel: p[3]->ip success
Jan 2 15:52:22 rhel4 kernel: p[3]->cp success
Jan 2 15:52:22 rhel4 kernel: p[4] success
Jan 2 15:52:22 rhel4 kernel: p[4]->ip success
Jan 2 15:52:22 rhel4 kernel: p[4]->cp success
Jan 2 15:52:22 rhel4 kernel: p[5] success
Jan 2 15:52:22 rhel4 kernel: p[5]->ip success
Jan 2 15:52:22 rhel4 kernel: p[5]->cp success
Jan 2 15:52:22 rhel4 kernel: p[6] success
Jan 2 15:52:22 rhel4 kernel: p[6]->ip success
Jan 2 15:52:22 rhel4 kernel: p[6]->cp success
Jan 2 15:52:22 rhel4 kernel: p[7] success
Jan 2 15:52:22 rhel4 kernel: p[7]->ip success
Jan 2 15:52:22 rhel4 kernel: p[7]->cp success
Jan 2 15:52:22 rhel4 kernel: p[8] success
Jan 2 15:52:22 rhel4 kernel: p[8]->ip success
Jan 2 15:52:22 rhel4 kernel: p[8]->cp success
Jan 2 15:52:22 rhel4 kernel: p[9] success
Jan 2 15:52:22 rhel4 kernel: p[9]->ip success
Jan 2 15:52:22 rhel4 kernel: p[9]->cp success
Jan 2 15:52:22 rhel4 kernel: pwmodule_wput
Jan 2 15:52:22 rhel4 kernel: pwmodule_close
Jan 2 15:52:22 rhel4 kernel: pw_close : 0
Jan 2 15:52:22 rhel4 kernel: pw_close : 1
Jan 2 15:52:22 rhel4 kernel: Unable to handle kernel paging request at
virtual address 70007468
Jan 2 15:52:22 rhel4 kernel: printing eip:
Jan 2 15:52:22 rhel4 kernel: c015053f
Jan 2 15:52:22 rhel4 kernel: *pde = 00000000
Jan 2 15:52:22 rhel4 kernel: Oops: 0000 [#1]
Jan 2 15:52:22 rhel4 kernel: Modules linked in: streams(U) mga parport_pc
lp parport autofs4 i2c_dev i2c_core sunrpc dm_mirror dm_multipath dm_mod
button battery ac md5 ipv6 uhci_hcd hw_random e100 mii floppy ext3 jbd
aic7xxx sd_mod scsi_mod
Jan 2 15:52:22 rhel4 kernel: CPU: 0
Jan 2 15:52:22 rhel4 kernel: EIP: 0060:[<c015053f>] Tainted: GF
VLI
Jan 2 15:52:22 rhel4 kernel: EFLAGS: 00010006 (2.6.9-16.EL)
Jan 2 15:52:22 rhel4 kernel: EIP is at kfree+0x23/0x49
Jan 2 15:52:22 rhel4 kernel: eax: 70007468 ebx: db052e40 ecx: e165fb72
edx: c1000000
Jan 2 15:52:22 rhel4 kernel: esi: 00000001 edi: 00000001 ebp: 00000202
esp: c6ce0e74
Jan 2 15:52:22 rhel4 kernel: ds: 007b es: 007b ss: 0068
Jan 2 15:52:22 rhel4 kernel: Process test (pid: 2697, threadinfo=c6ce0000
task=d2dcb890)
Jan 2 15:52:22 rhel4 kernel: Stack: db052e40 e164d22a 00000001 c6ce0ea0
e164d2e6 d8c3ec60 00000001 0000084a
Jan 2 15:52:22 rhel4 kernel: e1660889 e1644351 c3e8f928 db052c80
e163381d db052c80 00000000 d9535a78

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

I went through some documents related to kmalloc and kfree.
I am not able to fix the problem.

I am going to enclose the following along with this mail.

1. pwmodule.c
2. Makefile_pwmodule
3. Config
4. Makefile
5. test.c
6. ReadMe

( pwmodule.o, Config and Makefile are placed in " /usr/src/LiS/pkg/pw/ " )

Can any one suggest, how to overcome the above issue.
Thanks in advance.

regards,
kishore,packetware
Brian F. G. Bidulock
2006-01-02 20:17:54 UTC
Permalink
kishore,

In pw_close:

for (i = MAX - 1; i > 0; --i)

does not deallocate memory at p[0]->cp, p[0]->ip or p[0].

--brian
--
Brian F. G. Bidulock ¦ The reasonable man adapts himself to the ¦
***@openss7.org ¦ world; the unreasonable one persists in ¦
http://www.openss7.org/ ¦ trying to adapt the world to himself. ¦
¦ Therefore all progress depends on the ¦
¦ unreasonable man. -- George Bernard Shaw ¦
kishore
2006-01-03 03:30:59 UTC
Permalink
hi all,

I am working on LiS-2.18.0 ( downloaded from gcom.com) .
My Redhat and kernel versions are,
Redhat Enterprise Linux WS release 4 ( Nahant Update 2) with kernel version
2.6.9-16.EL .

I am facing a severe problem while deallocating the memory in my driver.
The whole scenario is as follows :

I wrote a driver and merged it with streams.
In the driver, just i am allocating memory for ten number of structures in
pw_open( ) and deallocating in pw_close( ).

I did the following steps to merge my driver into streams :

1. created a folder named "pw" /usr/src/LiS/pkg/
2. placed the Config, Makefile and pwmodule.o in /usr/src/LiS/pkg/pw/.
3. moved to /usr/src/LiS
4. make clean
5. make
6. make install
7. modprobe streams

When I am trying to unload streams using

8. rmmod streams
the system is going to hung.

The following lines are from /var/log/messages,

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

Jan 2 15:52:13 rhel4 kernel: Copyright (c) 1997-2004 David Grothe, et al,
http://www.gcom.com
Jan 2 15:52:13 rhel4 kernel: Major device number 254.
Jan 2 15:52:13 rhel4 kernel: Version 2.18.0r4 12/12/05. Compiled for kernel
version 2.6.9-16.EL.
Jan 2 15:52:13 rhel4 kernel: Using <linux/poll.h>
<LiS/include/sys/stropts.h>
Jan 2 15:52:13 rhel4 kernel: Kernel register args 3, LiS register args 0
Jan 2 15:52:13 rhel4 kernel:
==================================================================
Jan 2 15:52:13 rhel4 kernel: LiS-RunQ-2.18.0r4 running on CPU 0 pid=2685
Jan 2 15:52:14 rhel4 pam_timestamp_check: pam_timestamp: `/var/'
permissions are lax
Jan 2 15:52:19 rhel4 pam_timestamp_check: pam_timestamp: `/var/'
permissions are lax
Jan 2 15:52:22 rhel4 kernel: pwmodule_open
Jan 2 15:52:22 rhel4 kernel: p[0] success
Jan 2 15:52:22 rhel4 kernel: p[0]->ip success
Jan 2 15:52:22 rhel4 kernel: p[0]->cp success
Jan 2 15:52:22 rhel4 kernel: p[1] success
Jan 2 15:52:22 rhel4 kernel: p[1]->ip success
Jan 2 15:52:22 rhel4 kernel: p[1]->cp success
Jan 2 15:52:22 rhel4 kernel: p[2] success
Jan 2 15:52:22 rhel4 kernel: p[2]->ip success
Jan 2 15:52:22 rhel4 kernel: p[2]->cp success
Jan 2 15:52:22 rhel4 kernel: p[3] success
Jan 2 15:52:22 rhel4 kernel: p[3]->ip success
Jan 2 15:52:22 rhel4 kernel: p[3]->cp success
Jan 2 15:52:22 rhel4 kernel: p[4] success
Jan 2 15:52:22 rhel4 kernel: p[4]->ip success
Jan 2 15:52:22 rhel4 kernel: p[4]->cp success
Jan 2 15:52:22 rhel4 kernel: p[5] success
Jan 2 15:52:22 rhel4 kernel: p[5]->ip success
Jan 2 15:52:22 rhel4 kernel: p[5]->cp success
Jan 2 15:52:22 rhel4 kernel: p[6] success
Jan 2 15:52:22 rhel4 kernel: p[6]->ip success
Jan 2 15:52:22 rhel4 kernel: p[6]->cp success
Jan 2 15:52:22 rhel4 kernel: p[7] success
Jan 2 15:52:22 rhel4 kernel: p[7]->ip success
Jan 2 15:52:22 rhel4 kernel: p[7]->cp success
Jan 2 15:52:22 rhel4 kernel: p[8] success
Jan 2 15:52:22 rhel4 kernel: p[8]->ip success
Jan 2 15:52:22 rhel4 kernel: p[8]->cp success
Jan 2 15:52:22 rhel4 kernel: p[9] success
Jan 2 15:52:22 rhel4 kernel: p[9]->ip success
Jan 2 15:52:22 rhel4 kernel: p[9]->cp success
Jan 2 15:52:22 rhel4 kernel: pwmodule_wput
Jan 2 15:52:22 rhel4 kernel: pwmodule_close
Jan 2 15:52:22 rhel4 kernel: pw_close : 0
Jan 2 15:52:22 rhel4 kernel: pw_close : 1
Jan 2 15:52:22 rhel4 kernel: Unable to handle kernel paging request at
virtual address 70007468
Jan 2 15:52:22 rhel4 kernel: printing eip:
Jan 2 15:52:22 rhel4 kernel: c015053f
Jan 2 15:52:22 rhel4 kernel: *pde = 00000000
Jan 2 15:52:22 rhel4 kernel: Oops: 0000 [#1]
Jan 2 15:52:22 rhel4 kernel: Modules linked in: streams(U) mga parport_pc
lp parport autofs4 i2c_dev i2c_core sunrpc dm_mirror dm_multipath dm_mod
button battery ac md5 ipv6 uhci_hcd hw_random e100 mii floppy ext3 jbd
aic7xxx sd_mod scsi_mod
Jan 2 15:52:22 rhel4 kernel: CPU: 0
Jan 2 15:52:22 rhel4 kernel: EIP: 0060:[<c015053f>] Tainted: GF
VLI
Jan 2 15:52:22 rhel4 kernel: EFLAGS: 00010006 (2.6.9-16.EL)
Jan 2 15:52:22 rhel4 kernel: EIP is at kfree+0x23/0x49
Jan 2 15:52:22 rhel4 kernel: eax: 70007468 ebx: db052e40 ecx: e165fb72
edx: c1000000
Jan 2 15:52:22 rhel4 kernel: esi: 00000001 edi: 00000001 ebp: 00000202
esp: c6ce0e74
Jan 2 15:52:22 rhel4 kernel: ds: 007b es: 007b ss: 0068
Jan 2 15:52:22 rhel4 kernel: Process test (pid: 2697, threadinfo=c6ce0000
task=d2dcb890)
Jan 2 15:52:22 rhel4 kernel: Stack: db052e40 e164d22a 00000001 c6ce0ea0
e164d2e6 d8c3ec60 00000001 0000084a
Jan 2 15:52:22 rhel4 kernel: e1660889 e1644351 c3e8f928 db052c80
e163381d db052c80 00000000 d9535a78

/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/

I went through some documents related to kmalloc and kfree.
I am not able to fix the problem.

I am going to enclose the following along with this mail.

1. pwmodule.c
2. Makefile_pwmodule
3. Config
4. Makefile
5. test.c
6. ReadMe

( pwmodule.o, Config and Makefile are placed in " /usr/src/LiS/pkg/pw/ " )

Can any one suggest, how to overcome the above issue.
Thanks in advance.

regards,
kishore,packetware
Brian F. G. Bidulock
2006-01-03 04:18:33 UTC
Permalink
kishore,

Now pwmodule.c does not compile. Unmatched #endif. You cannot
possibly have tested this code.

--brian
--
Brian F. G. Bidulock ¦ The reasonable man adapts himself to the ¦
***@openss7.org ¦ world; the unreasonable one persists in ¦
http://www.openss7.org/ ¦ trying to adapt the world to himself. ¦
¦ Therefore all progress depends on the ¦
¦ unreasonable man. -- George Bernard Shaw ¦
Loading...