diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-11 16:08:25 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-18 00:56:32 +0200 |
commit | ac1e1b5fd7effb0925b3131290c3b5fab282bdaa (patch) | |
tree | 3ff5f10366de6b69233afb5781ec6d33d9e39b98 /src/shared | |
parent | dissect-image: introduce reference counter for DecryptedImage (diff) | |
download | systemd-ac1e1b5fd7effb0925b3131290c3b5fab282bdaa.tar.xz systemd-ac1e1b5fd7effb0925b3131290c3b5fab282bdaa.zip |
dissect-image: take reference of DecryptedImage into DissectedImage
No functional changes. Preparation for later commits.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/dissect-image.c | 12 | ||||
-rw-r--r-- | src/shared/dissect-image.h | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 5e1af80997..e97c22d796 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -1112,9 +1112,14 @@ DissectedImage* dissected_image_unref(DissectedImage *m) { if (!m) return NULL; + /* First, clear dissected partitions. */ for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) dissected_partition_done(m->partitions + i); + /* Second, free decrypted images. This must be after dissected_partition_done(), as freeing + * DecryptedImage may try to deactivate partitions. */ + decrypted_image_unref(m->decrypted_image); + free(m->image_name); free(m->hostname); strv_free(m->machine_info); @@ -2096,7 +2101,8 @@ int dissected_image_decrypt( return -EINVAL; if (!m->encrypted && !m->verity_ready) { - *ret = NULL; + if (ret) + *ret = NULL; return 0; } @@ -2130,7 +2136,9 @@ int dissected_image_decrypt( } } - *ret = TAKE_PTR(d); + m->decrypted_image = TAKE_PTR(d); + if (ret) + *ret = decrypted_image_ref(m->decrypted_image); return 1; #else diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h index 6dd5246042..7308798493 100644 --- a/src/shared/dissect-image.h +++ b/src/shared/dissect-image.h @@ -211,6 +211,7 @@ struct DissectedImage { bool single_file_system:1; /* MBR/GPT or single file system */ DissectedPartition partitions[_PARTITION_DESIGNATOR_MAX]; + DecryptedImage *decrypted_image; /* Meta information extracted from /etc/os-release and similar */ char *image_name; |