]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
driver core: faux: fix root device registration
authorJohan Hovold <johan@kernel.org>
Fri, 24 Apr 2026 15:31:26 +0000 (17:31 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Sat, 2 May 2026 15:50:31 +0000 (17:50 +0200)
commit580a795105dae2ef1622df72a27a8fb0605e2f6b
tree888cb9453ee9596f635b5e53a3552714fdc672b3
parent9db268212e0d7c7e3c4aef3494e55afbc1695b1f
driver core: faux: fix root device registration

A recent change made the faux bus root device be allocated dynamically
but failed to provide a release function to free the memory when the
last reference is dropped (on theoretical failure to register the device
or bus).

Fix this by using root_device_register() instead of open coding.

Also add the missing sanity check when registering faux devices to avoid
use-after-free if the bus failed to register (which would previously
have triggered a bunch of use-after-free warnings).

Fixes: 61b76d07d2b4 ("driver core: faux: stop using static struct device")
Cc: stable@vger.kernel.org # 7.0
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260424153127.2647405-2-johan@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/base/faux.c