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 81276C433F5 for ; Wed, 12 Jan 2022 17:23:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 734B0832EC; Wed, 12 Jan 2022 18:22:05 +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="KFpy0NW0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8D6ED83178; Wed, 12 Jan 2022 18:21:56 +0100 (CET) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (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 35C8F83420 for ; Wed, 12 Jan 2022 18:21:46 +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 ams.source.kernel.org (Postfix) with ESMTPS id DD760B82006; Wed, 12 Jan 2022 17:21:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 804B1C36AEC; Wed, 12 Jan 2022 17:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642008104; bh=od6T4MA7Q6xBGeHCo3k1W98F7oKZ4qec0t6JSD87Z+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFpy0NW0rhQoAPlXjzZdPNJQ5Zah2jde0NEsd2UOTYlNASYZYTzJ63GiUs50dWs8a wuCY0JUzYiKnVeEnOtULQyK5zjCOz7/HSUf4g9XqmK5ykihJda9+YM55JbwTDLptG8 iX6sByMni9WmqYaBt30atEZK9iJMQhw9dWdBoLY6l8y42QwliyR+PjUegWyW/5F679 W+u9Cnv8WYDQGfquR4o4PNaCicO40b1gSjCgay1Qu8rxE+1dtMSQyAEgkGOW0962AD GSycUCG2TqTcTSzzNyzHfJBnsvd+een/Bi31xLa44RgPZOjaHnoNTf0EBqhY6jIEdb BLMYjnaIlKRNg== Received: by pali.im (Postfix) id 35E05768; Wed, 12 Jan 2022 18:21:44 +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 v2 08/20] tools: kwbimage: Check the return value of image_headersz_v1() Date: Wed, 12 Jan 2022 18:20:42 +0100 Message-Id: <20220112172054.5961-9-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220112172054.5961-1-pali@kernel.org> References: <20211221155416.8557-1-pali@kernel.org> <20220112172054.5961-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.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.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 c0f1bdac0210..a5b518f60bc8 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2029,6 +2029,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