On Wed, 30 Mar 2005, P Lavin wrote:I'm using this flag only, this flag does not guarentee mem allocation,
Date: Wed, 30 Mar 2005 12:45:01 +0530
From: P Lavin <lavin.p@xxxxxxxxxxxxxxxxxx>
To: linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: no need to check for NULL before calling kfree() -fs/ext2/
Hi,
In my wlan driver module, i allocated some memory using kmalloc in interrupt
context, this one failed but its not returning NULL ,
kmalloc() should always return NULL if the allocation failed.
so i was proceeding
further everything was going wrong... & finally the kernel crahed. Can any one
of you tell me why this is happening ? i cannot use GFP_KERNEL because i'm
calling this function from interrupt context & it may block. Any other
If you need to allocate memory from interrupt context you should be using GFP_ATOMIC (or, if possible, do the allocation earlier in a different context).
I'm not checking this , but my explanation is given above.solution for this ?? I'm concerned abt why kmalloc is not returning null ifI have no explanation for that, are you sure that's really what's happening?
its not a success ??
Is it not necessary to check for NULL before calling kfree() ??
No, it is not nessesary to check for NULL before calling kfree() since kfree() does
void kfree (const void *objp)
{
... if (!objp)
return;
...
}
So, if you pass kfree() a NULL pointer it deals with it itself, you don't need to check that explicitly before calling kfree() - that's redundant.