From dbc7d6aa1964438e282be608262c3289feabd56b Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 15 Mar 2024 00:19:40 +0100 Subject: [PATCH] btrfs-progs: handle transaction start failure in set_label_unmounted() Do proper error handling and use the template error message when setting the label fails. Signed-off-by: David Sterba --- common/filesystem-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/filesystem-utils.c b/common/filesystem-utils.c index 8c159365..66269ad9 100644 --- a/common/filesystem-utils.c +++ b/common/filesystem-utils.c @@ -98,7 +98,10 @@ static int set_label_unmounted(const char *dev, const char *label) return -1; trans = btrfs_start_transaction(root, 1); - BUG_ON(IS_ERR(trans)); + if (IS_ERR(trans)) { + error_msg(ERROR_MSG_START_TRANS, "set label"); + return PTR_ERR(trans); + } __strncpy_null(root->fs_info->super_copy->label, label, BTRFS_LABEL_SIZE - 1); btrfs_commit_transaction(trans, root);