git: 7d6932d20aed - main - ctladm: Fix a race when loading ctl.ko
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 25 Jun 2024 19:29:36 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7d6932d20aedbbb220cd78e90ab4e82d1abaad31 commit 7d6932d20aedbbb220cd78e90ab4e82d1abaad31 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-06-24 15:09:18 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-06-25 19:29:03 +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 --- 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 95557406741c..5abc95cddc34 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -4469,7 +4469,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;