[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kernel malloc
Wouter Clarie <email@example.com> writes:
> in malloc(9) you can find that if using kernel malloc with M_WAITOK, it
> can never return NULL. Is this true in 100% of the cases? I'm doing a
> return value check of kernelland and there are quite a few cases where the
> return value is still checked when using M_WAITOK.
> Could anyone make this clear?
Sometimes I do a sweep for checked return values from M_WAITOK malloc. But
it was a long time ago last time.
When kernel malloc with M_WAITOK can fail it will panic with "out of space
in kmem_map" instead. It will never return NULL. The documentation is right.
People check the return value because they are used to, I guess the kernel
malloc shouldn't be called malloc if it doesn't have the same API and
semantics as userland, but I'm not going to change that.