Page MenuHomeFreeBSD

Reduce the scope of possible allocation failures in subr_kobj.c.
AbandonedPublic

Authored by markj on Jan 29 2019, 6:40 PM.

Details

Reviewers
None
Summary

Previously kobj_class_compile() would panic if its internal allocation
failed. kobj_class_compile() may be called from kobj_create() via
kobj_init(), and kobj_create() allows the caller to specify the wait
flags, so kobj_create(M_WAITOK) may trigger a panic due to an allocation
failure, which is silly.

Take a step towards fixing this: plumb the wait flags from kobj_create()
to kobj_class_compile(). I verified that all external callers of
kobj_class_compile() use it in a M_WAITOK context.

There is still a problem: kobj_init() does not provide a return value,
yet may fail due to the allocation failure. Moreover, it is sometimes
called in a non-sleepable context (e.g., device probe). I considered
adding an mflags parameter there, but wanted to get some feedback first.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 22255
Build 21457: arc lint + arc unit