[config] add some nonnull qualifiers
[config] fix CID 28481: pass big struct by pointer
[config] fix CID 28451: exit on memory error
[config] fix CID 28522: close dir on return