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 DA2BFC433F5 for ; Tue, 21 Dec 2021 15:57:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 54B5583383; Tue, 21 Dec 2021 16:56:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.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=kernel.org header.i=@kernel.org header.b="lnMM8F2B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FA1083615; Tue, 21 Dec 2021 16:56:10 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 81068831D7 for ; Tue, 21 Dec 2021 16:55:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 46F566162C; Tue, 21 Dec 2021 15:55:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90430C36AEE; Tue, 21 Dec 2021 15:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1640102146; bh=8Z2Ds+V3L9Q84iH2NO3Oxs4j4gEWgOfDJWBfhyoCFLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnMM8F2BpEOpI2aKhTotDPl4FDvc0HLI0FVlBPq7apYaOk6OgZBu/vWy5tR8IRsLW tn1CoOB6gMCNqDYjVdo5Do3W4G9p1ULBf1b/PCRcUVq5N1ANZXN12nyym6BL/dbUes B1TCorvZFoc0v8u9gkfZPsz0diCxOJedF6v7K+yA+TRWvQHby6ZSVIicQzqPLLNiNy 7298fDP7qhz5rQv7NyCKrPEdFiR12v1BLGXzThqfHncn65q/FQDu/HTWm2SQ1GvDwj QZmKbMqBbeWspE9qXSHoPUPK+dzKZeLwdkjX5SDeVRp1u9Q0q/VhxjhEVBZT+SQJ9I kFbkcohkoTOIg== Received: by pali.im (Postfix) id 49A03284D; Tue, 21 Dec 2021 16:55:46 +0100 (CET) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Chris Packham Cc: u-boot@lists.denx.de Subject: [PATCH u-boot-marvell 07/16] tools: kwbimage: Check the return value of image_headersz_v1() Date: Tue, 21 Dec 2021 16:54:07 +0100 Message-Id: <20211221155416.8557-8-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211221155416.8557-1-pali@kernel.org> References: <20211221155416.8557-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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.2 at phobos.denx.de X-Virus-Status: Clean Function image_headersz_v1() may return zero on fatal errors. In this case the function already printed an error message. Check the return value of image_headersz_v1() in kwbimage_generate(), and exit on zero value with EXIT_FAILURE. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún --- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index c21ed7b23fcf..7759a5f94098 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1984,6 +1984,10 @@ static int kwbimage_generate(struct image_tool_params *params, case 1: alloc_len = image_headersz_v1(NULL); + if (!alloc_len) { + free(image_cfg); + exit(EXIT_FAILURE); + } break; default: -- 2.20.1