From patchwork Wed May 6 14:05:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Bisson X-Patchwork-Id: 1284472 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=boundarydevices.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=boundarydevices-com.20150623.gappssmtp.com header.i=@boundarydevices-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=s72gJ281; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49HJKX44pVz9sRY for ; Thu, 7 May 2020 00:06:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4E62A82157; Wed, 6 May 2020 16:06:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=boundarydevices.com 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=boundarydevices-com.20150623.gappssmtp.com header.i=@boundarydevices-com.20150623.gappssmtp.com header.b="s72gJ281"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7910A8215F; Wed, 6 May 2020 16:06:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) (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 887648214B for ; Wed, 6 May 2020 16:06:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=boundarydevices.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=gary.bisson@boundarydevices.com Received: by mail-wr1-x443.google.com with SMTP id x17so2359694wrt.5 for ; Wed, 06 May 2020 07:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=idlKtdV8X6PuYh5CO8EPRCrGxUAPCeL7wt8fQet6EZw=; b=s72gJ281ex/09raqwUXcMJpLYuSFkzNPQJrXevPM38FvCy2O81AvpnKeX0nenMBLTa YXnmEThVNitggKbx4NW3oGqzzO5XWYAyXC1/TzWEmwxrxpOa0RaVXMqZodMXKpywW+Zc Huz5SShut2cB0FGLRIQR8lpUSVt5okVT6fV47MsoB44KIxe/A1irzqFyyP088Kga92gB bt1aJXQc4W/4WWMfKMl+ueIbwFP6b2U0Y1xuOpFkc0qNR4AKWj9qojMFKtPmHZd/qL+R jFrnrCClgSNO+rPbAm3S8ZGW2sGqdXpkgM40cYsNneMPHWcvnmywTFWFcCNPUxy6dyzr X5mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=idlKtdV8X6PuYh5CO8EPRCrGxUAPCeL7wt8fQet6EZw=; b=BJEZzlT6PR+tRW+drBBGsi9FO/SDitPpuObBYsTAy0HI15iIVkGIhs1s4RgpBoR694 JI4U+eHCZsCPKvOAxP653Zj7VCtBclXOqnI6Dc0WOaTTUOUaqpU7C6whTxEeSQ5hsgGB StfF4gRBdDzo4IleJ0d8ZLjbfJoraYcrtNBkXl+M7x6ZCYh3EJkB21YUG0wu+mydSPZ6 rdPr2whG1BRb86Hh+qvl7/Yxs/uX073yIKGKvmlgyAAvuPZVpHIqKUkUVTDisWB00AFb WFsYHtxASTXPr3sSQ4KXzvEgWXwxRHbdcdB2gFPisNSbsvMQ9izFG7/ROUUGcs9VHgt6 /W0Q== X-Gm-Message-State: AGi0PuYRoh19sFGtFZEiRXoAUbMyC8bIOf1nSXQ4GIPFDWNqaXiWdEve g84YNqZV8NsLTjOl22r2+ZqZq0JO5JE= X-Google-Smtp-Source: APiQypKO7fAX6vMoBlg7RB0CfXBrzcDo3QrJHRdnzpmNCFa3OvAfwyRvuwwCnMbDN6BddKWnJ2N0ug== X-Received: by 2002:adf:ecc3:: with SMTP id s3mr10466560wro.116.1588773959734; Wed, 06 May 2020 07:05:59 -0700 (PDT) Received: from p1g2.home (2a01cb000f89b400cc883edd44ec4519.ipv6.abo.wanadoo.fr. [2a01:cb00:f89:b400:cc88:3edd:44ec:4519]) by smtp.gmail.com with ESMTPSA id t2sm3258873wmt.15.2020.05.06.07.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 07:05:59 -0700 (PDT) From: Gary Bisson To: u-boot@lists.denx.de Cc: igor.opaniuk@gmail.com, Gary Bisson Subject: [PATCH] cmd: avb: free partition buffer upon verify completion Date: Wed, 6 May 2020 16:05:57 +0200 Message-Id: <20200506140557.505309-1-gary.bisson@boundarydevices.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Allows to run 'avb verify' multiple times which can be useful after a failure to be able to re-flash the partition and try again. Signed-off-by: Gary Bisson --- Hi, This was added because of the following scenario: 1- fastboot flash boot boot.img 2- avb verify -> fails because vbmeta wasn't updated 3- fastboot flash vbmeta vbmeta.img 4- avb verify -> fails because it can't allocate memory as previous buffer wasn't freed Let me know if you have any questions. Regards, Gary --- cmd/avb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/avb.c b/cmd/avb.c index a4de5c40a2..67154de4e1 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -312,6 +312,14 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, printf("Unknown error occurred\n"); } + /* Free image buffers now that verification is complete */ + if (slot_result != AVB_SLOT_VERIFY_RESULT_ERROR_OOM) { + int i; + for (i = 0; i < (int)out_data->num_loaded_partitions; i++) + if (out_data->loaded_partitions[i].data) + free(out_data->loaded_partitions[i].data); + } + return res; }