]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kenv: avoid sleepable alloc for integer tunables
authorJason A. Harmening <jah@FreeBSD.org>
Fri, 14 Aug 2020 21:37:38 +0000 (21:37 +0000)
committerJason A. Harmening <jah@FreeBSD.org>
Fri, 14 Aug 2020 21:37:38 +0000 (21:37 +0000)
commitf3ba85ccc84991e40e866e6e552d3d6960a16c28
treec795760341864d96aeb69579c3156a484e3b45e7
parent2f23f45b20ace184ddc5183d298a9f47cd9c2e33
kenv: avoid sleepable alloc for integer tunables

Avoid performing a potentially-blocking malloc for kenv lookups that will only
perform non-destructive integer conversions on the returned buffer. Instead,
perform the strtoq() in-place with the kenv lock held.

While here, factor the logic around kenv_lock acquire and release into
kenv_acquire() and kenv_release(), and use these functions for some light
cleanup. Collapse getenv_string_buffer() into kern_getenv(), as the former
no longer has any other callers and the only additional task performed by
the latter is a WITNESS check that hasn't been useful since r362231.

PR: 248250
Reported by: gbe
Reviewed by: mjg
Tested by: gbe
Differential Revision: https://reviews.freebsd.org/D26010
sys/kern/kern_environment.c