]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix a panic on boot introduced by 555a861d6826
authorAndrew Gallatin <gallatin@FreeBSD.org>
Tue, 1 Nov 2022 17:44:39 +0000 (13:44 -0400)
committerAndrew Gallatin <gallatin@FreeBSD.org>
Tue, 1 Nov 2022 17:44:39 +0000 (13:44 -0400)
commit8b19898a78d52b351f4d7a6ad1d8b074d037e3b7
treee14772af0c4248732571828d34922326baef3711
parent7366c0a49c9a60d3eea7520d7ae4bc2b3ab172f3
Fix a panic on boot introduced by 555a861d6826

First, an sbuf_new() in device_get_path() shadows the sb
passed in by dev_wired_cache_add(), leaving its sb in an
unfinished state, leading to a failed KASSERT().  Fixing this
is as simple as removing the sbuf_new() from device_get_path()

Second, we cannot simply take a pointer to the sbuf memory and
store it in the device location cache, because that sbuf
is freed immediately after we add data to the cache, leading
to a use-after-free and eventually a double-free.  Fixing this
requires allocating memory for the path.

After a discussion with jhb, we decided that one malloc was
better than two in dev_wired_cache_add, which is why it changed
so much.

Reviewed by: jhb
Sponsored by: Netflix
MFC after: 14 days
sys/kern/subr_bus.c