From patchwork Mon May 11 10:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Bisson X-Patchwork-Id: 1287592 X-Patchwork-Delegate: trini@ti.com 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=85.214.62.61; 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=fZif1BKT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 49LGv84nTHz9sSF for ; Mon, 11 May 2020 20:12:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B5CF8066C; Mon, 11 May 2020 12:12:01 +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="fZif1BKT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7AC68066F; Mon, 11 May 2020 12:11:59 +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-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (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 C48DD8056E for ; Mon, 11 May 2020 12:11:56 +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-x42a.google.com with SMTP id 50so9644992wrc.11 for ; Mon, 11 May 2020 03:11:56 -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=zvAzAa42THWRGIYXqrZKgm0S0WQrlPvw63CVtBkixA8=; b=fZif1BKTZ+hwUtD6Z06tNWSJMlUDkhUdZPYFxzmbmTQnFPqoxu2Rn+vlWqlvkbMAzS KhR+Tv1NOw3TnPAUWJRGvKjTofOcVlEK7IiSanPTUCHcLbHeK/Ktnb3mEbWRFAAwKDED rgL0VdatFzdsI8mZYxrwx6VFRCniHb5NESKn9fCWoQJ6oLiygUg8oVOqaRC2JefwK4OJ R8XfUNNu3UnyKqgYgPAUHA0ewYYYf/bIl0OqOTWWH3q4p0dDpxMITy6Bd0Sz1S0GJfU6 iTMF6WsXVImkWCm6UhE/FGFlSMFhNdEWEOoQFOQ30+FoWQxioaGhcXSvbd01uaJEslZ3 Crsg== 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=zvAzAa42THWRGIYXqrZKgm0S0WQrlPvw63CVtBkixA8=; b=m+dYXDwQeTNKO1YgZG6sKGevEdVhFWqVB/xcADfh/ovtPaIwZF4vKT1x0q4NWG0nTb Eul6d5eDCDlR/YdtiRJr31EuZoLnJEAqqrKuqHcYDzp3tgL8Gyn0RmIgJT0nvfRFSDEt 92xVpQ3Wp7hWDDmJpOFuGjIR1UF+Rs8yyqiovaXuu6nItzjIENKcQx9z0XoQAfvUd2n6 ACw/LJyexpCt0+/sT6yhmfGrWPTm0xMaGP2MqhB6ATkz8U5dvXk5yKZcobInZQppg+N6 hS2TC4UcB0W41nyMS3T5G7hfE6gCsx19wtLOZbh/TUmUZjh/a7dO8rjJkfpq/IowLoUn NJsQ== X-Gm-Message-State: AGi0Pub9ukjauWZQafcHc5saNcpuWqQGnKkPUdVFrOaJoYsnLOtJKhM6 M1j59s351GEDidrC7FPsvps5upMXj78= X-Google-Smtp-Source: APiQypKLjn8QHHdLCg5CK5u47le+qewC1GyQ02/GD1/LJ3GfwUKS3clLQ5Cs0zaZXK/q/GGsClYtaA== X-Received: by 2002:adf:fa47:: with SMTP id y7mr17045462wrr.337.1589191916081; Mon, 11 May 2020 03:11:56 -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 g6sm875752wrp.75.2020.05.11.03.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 03:11:55 -0700 (PDT) From: Gary Bisson To: u-boot@lists.denx.de Cc: igor.opaniuk@gmail.com, Gary Bisson Subject: [PATCH v2] cmd: avb: free partition buffer upon verify completion Date: Mon, 11 May 2020 12:11:53 +0200 Message-Id: <20200511101153.20396-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 Doing the same as the unittests for libavb [1]. 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. [1] https://android.googlesource.com/platform/external/avb/+/refs/tags/android-9.0.0_r37/test/avb_slot_verify_unittest.cc#156 Signed-off-by: Gary Bisson Reviewed-by: Igor Opaniuk --- Hi, Changelog v2: - use avb_slot_verity_data_free as suggested by Igor 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/avb.c b/cmd/avb.c index a4de5c40a2..93d1a31819 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -312,6 +312,9 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, printf("Unknown error occurred\n"); } + if (out_data) + avb_slot_verify_data_free(out_data); + return res; }