git: 1a0314d6e305 - stable/14 - ctladm: Fix a race when loading ctl.ko
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 Jul 2024 13:22:36 UTC
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1a0314d6e30554fc2b07caa5121b00956f416cc4 commit 1a0314d6e30554fc2b07caa5121b00956f416cc4 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-06-24 15:09:18 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-07-02 13:19:29 +0000 ctladm: Fix a race when loading ctl.ko If multiple ctladm processes try to load ctl.ko at the same time, only one will succeed. Handle this possibility by retrying the operation (open /dev/cam/ctl) if kldload returns EEXIST, rather than bailing. This at least helps ensure that ctladm tests can be run in parallel when ctl.ko is not preloaded. Reviewed by: asomers MFC after: 1 week (cherry picked from commit 7d6932d20aedbbb220cd78e90ab4e82d1abaad31) --- usr.sbin/ctladm/ctladm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index e99610373ff0..228af7bae8c6 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -4133,7 +4133,7 @@ main(int argc, char **argv) if (fd == -1 && errno == ENOENT) { saved_errno = errno; retval = kldload("ctl"); - if (retval != -1) + if (retval != -1 || errno == EEXIST) fd = open(device, O_RDWR); else errno = saved_errno;