LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-29-2003, 11:03 AM   #1
dipakn
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Rep: Reputation: 0
Question kmalloc returning overlapped address


It seems to me that kmalloc function in my code is returning overlapped memory. In my code a process from the user space calls a function in the kernel space (driver code). The kernel space function allocates memory as part of this kernel space function execution. The process in the user space calls the kernel space driver function twice consecutively. The kmalloc call get called twice (one for each invocation of the kernel space function). The kmalloc call allocates a memory of size 2592 bytes( a structure of this size). I noticed that in the 2nd invocation of the kmalloc, it returns a memory space which overlapped with the first time kmalloc call. I have logged the first byte address and last byte address of the structure allocated in the /var/log/message. Below is the address that I got on both the times:

Fist time kamalloc:
*createFcpTapeDriveCB, 1st address: 0xf5dbc800, 2nd address: 0xf5dbd220, size: 2592 *
*createFcpTapeDriveCB, last address: 0xf5dbd21c *

2nd time kmalloc:
*createFcpTapeDriveCB, 1st address: 0xf5dbc200, 2nd address: 0xf5dbcc20, size: 2592 *
*createFcpTapeDriveCB, last address: 0xf5dbcc1c *

Here the last address: is the address of the last variable in the structure (a 32 bit pointer). 1st address is the address of the first variable in the structure and 2nd address is the first address + sizeof(structure allocated).

Can anybody help me in this regard? Why kmalloc returns overlapped address? I am running kernel version:
[root@indigo2 fcpTape]# uname -a
Linux indigo2 2.4.19smp #3 SMP Mon Jun 16 23:25:54 IST 2003 i686 unknown


Thanks,
Dipak
 
Old 10-29-2003, 07:11 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
Is kmalloc returning the address of a memory block or is kmalloc returning a pointer to the address of a memory block?


---------------
Steve Stites
 
Old 10-29-2003, 10:07 PM   #3
dipakn
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Original Poster
Rep: Reputation: 0
This is my kmalloc call:

/* Call the kernel malloc to allocate memory for fcpTapeDriveCB. */
pFcpTapeDCB = (fcpTapeDriveCB *)kmalloc(GFP_KERNEL, sizeof(fcpTapeDriveCB));

It returns pointer to the allocated memory block.

Thanks,
Dipak
 
Old 10-29-2003, 10:54 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,346

Rep: Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552Reputation: 552
I am not certain but I would try:

pFcpTapeDCB = (fcpTapeDriveCB *)*kmalloc(GFP_KERNEL, sizeof(fcpTapeDriveCB));

instead of:

pFcpTapeDCB = (fcpTapeDriveCB *)kmalloc(GFP_KERNEL, sizeof(fcpTapeDriveCB));


___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 10-29-2003, 11:29 PM   #5
dipakn
LQ Newbie
 
Registered: Oct 2003
Posts: 3

Original Poster
Rep: Reputation: 0
The problem got fixed. Actually the problem was the way I was using the kmalloc:

pFcpTapeDCB = (fcpTapeDriveCB *)kmalloc(sizeof(fcpTapeDriveCB), GFP_KERNEL);

Here the priority should be the 2nd argument. I was using priority as the first argument.

Thanks a lot for your time.
Dipak
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird card problem - DHCP returning IPv6 address lacitpo Linux - Wireless Networking 2 03-16-2005 11:28 PM
screenshots with X from overlapped or not visible windows ceo2 Linux - Software 0 12-01-2004 11:10 AM
gethostbyname() is not returning my IP address hal2000 Programming 5 10-11-2004 05:54 PM
Program returning ip-address? smellofsunshine Linux - Software 4 08-11-2003 05:59 AM
Kmalloc returns null iannou Linux - General 0 06-28-2003 10:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration