]> git.alsa-project.org Git - alsa-utils.git/commit
alsactl: Fix race at creating a lock file
authorTakashi Iwai <tiwai@suse.de>
Fri, 11 Dec 2020 22:46:23 +0000 (23:46 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Dec 2020 22:46:23 +0000 (23:46 +0100)
commitc53f7cd03881092d5a61505d23ab8f920b7faf12
tree9e6664920c0202508be292130504624ab62f80dd
parent878e1a7c0f03233530e7675ae015aced069c971d
alsactl: Fix race at creating a lock file

A race at creating a lock file in state_lock() was discovered
recently: namely, between the first open(O_RDWR) and the second
open(O_RDWR|O_CREAT|O_EXCL) calls, another alsactl invocation may
already create a lock file, then the second open() will return EEXIST,
which isn't handled properly and treated as a fatal error.

In this patch, we check EEXIST case and try again open() with O_RDWR.
This must succeed usually, and if it fails, handle finally as the
fatal error.

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1179904
Signed-off-by: Takashi Iwai <tiwai@suse.de>
alsactl/lock.c