> It looks like malloc() can return NULL if the kmem_malloc() fails. Not for the M_WAITOK case.
> kmem_malloc() can only fail in the M_WAITOK case if the KVM map is full. kmem_malloc() panics in this case (except for map == mb_map; the mbuf allocator has special handling for this problem). > If the system is simply low on memory, kmem_malloc() will block. > > So malloc() will generally not return NULL even in low memory situations > unless the KVM map fills up, which isn't supposed to happen but can in > certain severe circumstances. Callers should therefore check for NULL. Callers that check for NULL are bogus. Callers that can actually handle low memory conditions should use M_NOWAIT. There should probably be a flag that says to wait for everything except the map to unfill, and this flag should have been used instead of the `map == mb_map' hack, but no callers actually handle filling of their map (the mbuf allocator doesn't -- it tends to panic a little later because m_retry[hdr]() is not prepared to pass failures back to callers in the can-wait case). Bruce To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-current" in the body of the message