Page MenuHomeFreeBSD

stand/kmem_zalloc: panic when a M_WAITOK allocation fails
ClosedPublic

Authored by imp on Jul 8 2021, 5:41 AM.
Tags
None
Referenced Files
F121907436: D31106.id91986.diff
Mon, Jun 30, 1:19 PM
Unknown Object (File)
Fri, Jun 27, 6:39 AM
Unknown Object (File)
Fri, Jun 27, 3:24 AM
Unknown Object (File)
Thu, Jun 26, 12:51 PM
Unknown Object (File)
Wed, Jun 25, 10:44 AM
Unknown Object (File)
Mon, Jun 23, 12:01 PM
Unknown Object (File)
Sun, Jun 22, 3:12 AM
Unknown Object (File)
Fri, Jun 20, 11:15 PM
Subscribers
None

Details

Summary

Malloc() might return NULL, in which case we will panic with a NULL
pointer deref. Make it panic when the allocation fails to preserve the
postcondtion that we never return a non-NULL value.

PR: 249859
Sponsored by: Netflix

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 40400
Build 37289: arc lint + arc unit

Event Timeline

imp requested review of this revision.Jul 8 2021, 5:41 AM
imp created this revision.
imp added inline comments.
sys/sys/malloc.h
322

This crept in because we never were testing flags before.

sys/sys/malloc.h
308

Shouldn't this order be reversed? or maybe create inline [function] instead? just thinking...

sys/sys/malloc.h
308

Order of what?
It can't be an inline function because I want FILE and LINE and I didn't see a good way to get that with an inline function.

309

This should be if (p == 0 && (flags & M_WAITOK) != 0)

update and make sure p == NULL before panicing.

Seems good, thanks!

sys/sys/malloc.h
308

Order of what?
It can't be an inline function because I want FILE and LINE and I didn't see a good way to get that with an inline function.

This revision is now accepted and ready to land.Jul 9 2021, 6:40 AM