From mboxrd@z Thu Jan 1 00:00:00 1970 From: AKASHI Takahiro Date: Mon, 2 Dec 2019 09:49:41 +0900 Subject: [U-Boot] [PATCH v2 04/16] efi_loader: add signature database parser In-Reply-To: <20191128144950.GA24434@apalos.home> References: <20191126005120.31156-1-takahiro.akashi@linaro.org> <20191126005120.31156-5-takahiro.akashi@linaro.org> <20191128142101.GA23148@apalos.home> <20191128144950.GA24434@apalos.home> Message-ID: <20191202004940.GT22427@linaro.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, Nov 28, 2019 at 04:49:50PM +0200, Ilias Apalodimas wrote: > On Thu, Nov 28, 2019 at 04:21:01PM +0200, Ilias Apalodimas wrote: > > Akashi-san, > > > > On Tue, Nov 26, 2019 at 09:51:08AM +0900, AKASHI Takahiro wrote: > > > efi_signature_parse_sigdb() is a helper function will be used to parse > > > signature database variable and instantiate a signature store structure > > > in later patches. > > > > > > Signed-off-by: AKASHI Takahiro > > > --- > > > include/efi_loader.h | 3 + > > > lib/efi_loader/efi_signature.c | 227 +++++++++++++++++++++++++++++++++ > > > 2 files changed, 230 insertions(+) > > > > > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > > index 622bae6a6906..5297fb854905 100644 > > > --- a/include/efi_loader.h > > > +++ b/include/efi_loader.h > > > @@ -720,6 +720,9 @@ bool efi_signature_verify_with_sigdb(struct efi_image_regions *regs, > > > efi_status_t efi_image_region_add(struct efi_image_regions *regs, > > > const void *start, const void *end, > > > int nocheck); > > > + > > > +void efi_sigstore_free(struct efi_signature_store *sigstore); > > > +struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name); > > > #endif /* CONFIG_EFI_SECURE_BOOT */ > > > > > > #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ > > > diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c > > > index 87a39b790f67..9be13d5a4bbe 100644 > > > --- a/lib/efi_loader/efi_signature.c > > > +++ b/lib/efi_loader/efi_signature.c > > > @@ -581,4 +581,231 @@ efi_status_t efi_image_region_add(struct efi_image_regions *regs, > > > > > > return EFI_SUCCESS; > > > } > > > + > > > +/** > > > + * efi_sigstore_free - free signature store > > > + * @sigstore: Pointer to signature store structure > > > + * > > > + * Feee all the memories held in signature store and itself, > > > + * which were allocated by efi_sigstore_parse_sigdb(). > > > + */ > > > +void efi_sigstore_free(struct efi_signature_store *sigstore) > > > +{ > > > + struct efi_signature_store *sigstore_next; > > > + struct efi_sig_data *sig_data, *sig_data_next; > > > + > > > + while (sigstore) { > > > + sigstore_next = sigstore->next; > > > + > > > + sig_data = sigstore->sig_data_list; > > > + while (sig_data) { > > > + if (sig_data) > > > + sig_data_next = sig_data->next; > > > > Why the extra if check? > > Looking at it again, maybe this is a typo and you wanted to > check sig_data->next? The check is just redundant. Will remove it. Thanks, -Takahiro Akashi > > > > > + free(sig_data->data); > > > + free(sig_data); > > > + sig_data = sig_data_next; > > > + } > > > + > > > + free(sigstore); > > > + sigstore = sigstore_next; > > > + } > > > +} > > > + > > > > Thnaks > > /Ilias