From: Fernando Jimenez <f.jimenez@bigfoot.com>
To: linux-kernel@vger.kernel.org
Subject: array size limit in module?
Date: Thu, 10 Jan 2002 18:13:53 +0000 [thread overview]
Message-ID: <20020110181054Z289122-13997+3040@vger.kernel.org> (raw)
Hi
I am trying to code a simple kernel module and I have found a problem I don't
quite understand.
Here is the offending part of code:
char *sectors_array = NULL;
........
secs_size=131072;
sectors_array = kmalloc(secs_size*sizeof(char), GFP_KERNEL);
for(i=0; i<secs_size; i++) {
sectors_array[i]=0;
}
This bit of code, as it is, works fine. However, if I increment secs_size by
one, ie, I do 'secs_size=131073;' instead of 131072, I get the following:
Unable to handle kernel NULL pointer dereference at virtual address 00000000
Jan 10 18:14:47 localhost kernel: printing eip:
Jan 10 18:14:47 localhost kernel: c4829475
Jan 10 18:14:47 localhost kernel: *pde = 00000000
Jan 10 18:14:47 localhost kernel: Oops: 0002
Jan 10 18:14:47 localhost kernel: CPU: 0
Jan 10 18:14:47 localhost kernel: EIP: 0010:[<c4829475>] Not tainted
Jan 10 18:14:47 localhost kernel: EFLAGS: 00000297
Jan 10 18:14:47 localhost kernel: eax: 00000000 ebx: 00000000 ecx:
00000001 edx: c1467f64
Jan 10 18:14:47 localhost kernel: esi: 000000fe edi: 00000000 ebp:
c3567f28 esp: c3567f20
Jan 10 18:14:47 localhost kernel: ds: 0018 es: 0018 ss: 0018
Jan 10 18:14:47 localhost kernel: Process insmod (pid: 979,
stackpage=c3567000)
Jan 10 18:14:47 localhost kernel: Stack: c4829000 00000000 0806fc58 c011a1e5
00000000 c2f70000 00000d30 c3c0a000
Jan 10 18:14:47 localhost kernel: 00000060 ffffffea 00000007 c0a423cc
00000060 c02caac0 c4829060 00000f90
Jan 10 18:14:47 localhost kernel: 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
Jan 10 18:14:47 localhost kernel: Call Trace: [<c011a1e5>] [<c4829060>]
[<c01075bb>]
Jan 10 18:14:47 localhost kernel:
Jan 10 18:14:47 localhost kernel: Code: c6 04 03 00 83 ec 08 53 68 ce 9c 82
c4 e8 a9 f8 8e fb 83 c4
I'm using kernel version 2.4.17 under RH7.2. I originally thought It could be
related to lack of memory. 'free' returns this:
total used free shared buffers cached
Mem: 61672 54828 6844 0 1972 41060
-/+ buffers/cache: 11796 49876
Swap: 321292 0 321292
but there is plenty of swap space in there. I also tried increasing the RAM
to 128Mb but that didn't help either
Any help will be very much appreciated, and sorry if I'm making an obvious
mistake. I'm quite new to kernel programming. :)
FJ
next reply other threads:[~2002-01-10 18:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-10 18:13 Fernando Jimenez [this message]
2002-01-10 18:18 ` Brian Gerst
2002-01-10 18:37 ` Benjamin LaHaise
2002-01-10 22:01 ` Alex Bligh - linux-kernel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020110181054Z289122-13997+3040@vger.kernel.org \
--to=f.jimenez@bigfoot.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®