Re: freeing memory

From: Marcus Sundberg (marcus@cendio.se)
Date: Sun Oct 22 2000 - 04:06:07 EST


mdaljeet@in.ibm.com writes:

> hi,
>
> i am allocating some 1000 bytes of memory as folows
>
> f_malloc()
> {
> .....
> for (i=1 to 10)
> {
> size = 1000;
> pAddr[i] = (unsigned long) kmalloc(size, GFP_DMA | GFP_BUFFER);

[snip]

> pAddr is defined as 'unsigned long pAddr[10]'
>
> But when f_free executes i ran into problems and computer hangs.
> What can be the problem?????

i == 10 will write past the end of your array.
Get a good book about C and read it.

//Marcus

-- 
-------------------------------+-----------------------------------
        Marcus Sundberg        |       Phone: +46 707 452062
  Embedded Systems Consultant  |      Email: marcus@cendio.se
       Cendio Systems AB       |       http://www.cendio.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 23 2000 - 21:00:18 EST