From 9972e6d6ed20a0af5d954e68de41221c657ccc54 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 17 Sep 2022 05:11:43 +0900 Subject: [PATCH] dissect-image: make verity_partition() actually fail when all attempts of activation failed --- src/shared/dissect-image.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index d6a2ab99ce1..274c33c35e4 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -2021,17 +2021,19 @@ static int verity_partition( } } if (r >= 0) - break; + goto success; /* Device is being opened by another process, but it has not finished yet, yield for 2ms */ (void) usleep(2 * USEC_PER_MSEC); } - /* An existing verity device was reported by libcryptsetup/libdevmapper, but we can't use it at this time. - * Fall back to activating it with a unique device name. */ - if (r < 0 && FLAGS_SET(flags, DISSECT_IMAGE_VERITY_SHARE)) + /* All trials failed. Let's try to activate with a unique name. */ + if (FLAGS_SET(flags, DISSECT_IMAGE_VERITY_SHARE)) return verity_partition(designator, m, v, verity, flags & ~DISSECT_IMAGE_VERITY_SHARE, d); + return log_debug_errno(SYNTHETIC_ERRNO(EBUSY), "All attempts to activate verity device %s failed.", name); + +success: /* Everything looks good and we'll be able to mount the device, so deferred remove will be re-enabled at that point. */ restore_deferred_remove = mfree(restore_deferred_remove); -- 2.47.3