]> xenbits.xensource.com Git - libvirt.git/commit
nodedev: Don't join not spawned threads
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 12 Apr 2021 14:25:13 +0000 (16:25 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Apr 2021 07:33:22 +0000 (09:33 +0200)
commite65d4917a445f45c0219f9a07144c0f7549709db
tree1ecd4c23c3c65ea2d9b64009511879628054ae67
parent3d3435e39510412604b7427285497a4e5e39cad5
nodedev: Don't join not spawned threads

During the nodedev driver initialization two threads are created:
one for listening on udev events (like device plug/unplug) and
the other for enumerating devices (so that the main thread doing
the driver init is not blocked). If something goes wrong at any
point then nodeStateCleanup() is called which joins those two
threads (possibly) created before. But it tries to join them even
they weren't created which is undefined behaviour (and it just so
happens that it crashes on my system).

If those two virThread variables are turned into pointers then we
can use comparison against NULL to detect whether threads were
created.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/node_device/node_device_udev.c