From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DC63C4332F for ; Fri, 11 Nov 2022 12:53:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0536F84DF8; Fri, 11 Nov 2022 13:53:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EdRdibYV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C418A850D4; Fri, 11 Nov 2022 13:53:49 +0100 (CET) Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4EA5480FB5 for ; Fri, 11 Nov 2022 13:53:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62c.google.com with SMTP id bj12so12281567ejb.13 for ; Fri, 11 Nov 2022 04:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Yoxf2TgmfyVYen4Poc5KE/5ut+GzdZHto6+JRYYvS90=; b=EdRdibYVV205cua0Zl+T0DxDLx9uXky2SCLCyczENjXQuTZ//gzIr8kbxrqx8UoSYB 52wz5MHB8gK74taQyxPCxRregEJRlTuhNJsO6hTQyGf28Phc21agZejeId9mAlTTXqjW hn5pP4hClcgJHqiYu73VXIscaPhKQiZMVES9WjQJXMu+sEHSUG2QkywEj6WujZ9/xS1p LWKmSkof2A+Idqpzjw3BjW1LbHJClSQzXUN/Q2n7sdCgZK9W79WvW3kTAjXUY1iDL8Q2 Vs7AiL8ODxIqG+ZR0w63RxCDDksJqj0x1d3ltb/Fe1Y9sJ4Ao1RALQ5bl/Dg2jVVGOSj Igbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yoxf2TgmfyVYen4Poc5KE/5ut+GzdZHto6+JRYYvS90=; b=qG2LVcdm4VKUfenA8NwDut0XBwHySyOVfFGfY9/ukq6i066tp/IAvSBeq4phpeIxGO tsZakgEQ5namy2y/YJ9fD8L4u4tjJbZwtxmPggi/HRpZtbiNCB2/5/HipNiWbrBxtiCZ PZFZ8pXuTnfxrcKijhiLV/I4rFU23QIKBd6cxEkGGf6mts6zRafC/gKFqGVk3W3z/Ie/ SDpDYGZ06Ra/U9oWv3IS2qmqZo6YpfIWBVJHH33WMbpMTYAVTvU1p2ANodEfdCXrHjr3 EOEHYo+k/bT3rhs5txNByGa3NMkoo1st2Zi4f3xmEy2r8cAI8wi8v97SOHPJ6tpbC2ah qoug== X-Gm-Message-State: ANoB5pkZmP+ce1i+Q7HshDq/r/CYSN6QRf75pIzWTftg36f94BwoQPRQ hPm+EoAbVTKUHQWqPlvZfMHZZQ== X-Google-Smtp-Source: AA0mqf76oh9UK4NPrXVvN7ketBh5Nkzmj8N94uULgKc4rFCaWbgXnXz9y4ZMhGEY8ivVX8TasVphRQ== X-Received: by 2002:a17:907:a683:b0:78c:3042:6919 with SMTP id vv3-20020a170907a68300b0078c30426919mr1621657ejc.377.1668171226959; Fri, 11 Nov 2022 04:53:46 -0800 (PST) Received: from hera ([46.198.253.211]) by smtp.gmail.com with ESMTPSA id ml21-20020a170906cc1500b007828150a2f1sm871873ejb.36.2022.11.11.04.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 04:53:46 -0800 (PST) Date: Fri, 11 Nov 2022 14:53:44 +0200 From: Ilias Apalodimas To: Masahisa Kojima Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Simon Glass , Takahiro Akashi , Etienne Carriere Subject: Re: [PATCH v8 5/5] eficonfig: add "Show Signature Database" menu entry Message-ID: References: <20221110083054.11950-1-masahisa.kojima@linaro.org> <20221110083054.11950-6-masahisa.kojima@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221110083054.11950-6-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean [...] > +/** > + * prepare_signature_list_menu() - create the signature list menu entry > + * > + * @efimenu: pointer to the efimenu structure > + * @varname: pointer to the variable name > + * @db: pointer to the variable raw data > + * @db_size: variable data size > + * @func: callback of each entry > + * Return: status code > + */ > +static efi_status_t prepare_signature_list_menu(struct efimenu *efi_menu, void *varname, > + void *db, efi_uintn_t db_size, > + eficonfig_entry_func func) > +{ > + u32 num = 0; > + efi_uintn_t size; > + struct eficonfig_sig_data *sg; > + struct efi_signature_list *esl; > + struct efi_signature_data *esd; > + efi_status_t ret = EFI_SUCCESS; > + > + INIT_LIST_HEAD(&efi_menu->list); > + > + esl = db; > + size = db_size; > + while (size > 0) { > + u32 remain; > + > + esd = (struct efi_signature_data *)((u8 *)esl + > + (sizeof(struct efi_signature_list) + > + esl->signature_header_size)); > + remain = esl->signature_list_size - sizeof(struct efi_signature_list) - > + esl->signature_header_size; > + for (; remain > 0; remain -= esl->signature_size) { > + char buf[40]; > + char *title; > + > + if (num >= EFICONFIG_ENTRY_NUM_MAX - 1) { > + ret = EFI_OUT_OF_RESOURCES; > + goto out; > + } > + > + sg = calloc(1, sizeof(struct eficonfig_sig_data)); > + if (!sg) { > + ret = EFI_OUT_OF_RESOURCES; > + goto err; > + } > + > + snprintf(buf, sizeof(buf), "%pUL", &esd->signature_owner); > + title = calloc(1, (strlen(buf) + 1)); > + if (!title) { > + free(sg); > + ret = EFI_OUT_OF_RESOURCES; > + goto err; > + } > + strlcpy(title, buf, strlen(buf) + 1); > + > + sg->esl = esl; > + sg->esd = esd; > + sg->varname = varname; > + ret = eficonfig_append_menu_entry(efi_menu, title, func, sg); > + if (ret != EFI_SUCCESS) { > + free(sg); > + free(title); > + goto err; > + } title and sg are allocated on a for loop. I assume that those will eventually be freed by eficonfig_destroy(). But shouldn't we call that on failures as well instead of just freeing the last instance? > + esd = (struct efi_signature_data *)((u8 *)esd + esl->signature_size); > + num++; > + } > + > + size -= esl->signature_list_size; > + esl = (struct efi_signature_list *)((u8 *)esl + esl->signature_list_size); > + } > +out: > + ret = eficonfig_append_quit_entry(efi_menu); > +err: > + return ret; > +} > + > +/** [...] Regards /Ilias