mirror of
https://github.com/torvalds/linux.git
synced 2026-11-25 16:02:57 +00:00
Commit3e6c6f630a("Delay creation of khcvd thread") moved the call of hvc_init from being a device_initcall into hvc_alloc, and used a non-null hvc_driver as indication of whether hvc_init had already been called. The problem with this is that hvc_driver is only assigned a value at the bottom of hvc_init, and so there is a window where multiple hvc_alloc calls can be in progress at the same time and hence try and call hvc_init multiple times. Previously the use of device_init guaranteed that hvc_init was only called once. This manifests itself as sporadic instances of two hvc_init calls racing each other, and with the loser of the race getting -EBUSY from tty_register_driver() and hence that virtual console fails: Couldn't register hvc console driver virtio-ports vport0p1: error -16 allocating hvc for port Here we add an atomic_t to guarantee we'll never run hvc_init twice. Cc: [email protected] # v2.6.24+ Cc: Rusty Russell <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Fixes:3e6c6f630a("Delay creation of khcvd thread") Reported-by: Jim Somerville <[email protected]> Tested-by: Jim Somerville <[email protected]> Signed-off-by: Paul Gortmaker <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>