mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-11-07 04:36:52 -10:00
virtio_random: avoid using vtrnd_detach in the failure path
On the off chance that we discover more than one virtio-random device, the second one will deregister the global instance or trip an invariant when it fails to attach and calls vtrnd_detach(). We don't have that many resources to free, so just inline those. This is purely a hygiene thing, we haven't seen an instance of this in the wild (to my knowledge). Reviewed by: bnovkov, kfv Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D61050
This commit is contained in:
1 parent
db8444c1b7
commit
26ba71f73e
1 file changed
+9
-2
@@ -184,8 +184,15 @@ vtrnd_attach(device_t dev)
|
||||
vtrnd_enqueue(sc);
|
||||
|
||||
fail:
|
||||
if (error)
|
||||
vtrnd_detach(dev);
|
||||
if (error != 0) {
|
||||
/* Parent will free the virtqueue. */
|
||||
if (g_vtrnd_softc == sc) {
|
||||
atomic_store_explicit(&g_vtrnd_softc, NULL,
|
||||
memory_order_release);
|
||||
}
|
||||
sglist_free(sc->vtrnd_sg);
|
||||
zfree(sc->vtrnd_value, M_DEVBUF);
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user