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 3BAB7EB64DC for ; Sun, 25 Jun 2023 10:35:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 276C7861A5; Sun, 25 Jun 2023 12:35:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1687689308; bh=MfnA+NFk22FNtfNzlJl+mQHZOIDKM8a49mph8Jl4JME=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=QJ1WsAqJJ4RYpXghJGSezT3mn4R8vSX4CrfyvtQi6SlvcNjHZ/Xq48Xp1E7XWxmab CkaA0iehh21LOpqX5OWeXlc+yvO6jHGx1d6x3VXaF83quuEftSJq8xeUNpYruXRB/A SE5FITUtbPVumq9d3C5QT6FSvt2s5ll+PUKJpJ2Y7CaqlrAr9/hjz5KgqeGJJIpH40 6ivxle/imDEOrnUm7dsky/Iqhyp8mx+PzxUohXCxg6IyOiIgRcCyiQ9xnzHtxSQZA4 hNBidZMfyAJfLTBOcO+FoZLI8JSONRoh/Bc69l+KzMptecx41TeZ0AVW8yt7LVwy+O v6Rp/MqHi/xXA== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id AF2A9860A6; Sun, 25 Jun 2023 12:35:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1687689303; bh=MfnA+NFk22FNtfNzlJl+mQHZOIDKM8a49mph8Jl4JME=; h=From:To:Cc:Subject:Date:From; b=wxmPQ1S15ZsoYyhcU9g3jpaqeOoul3bZE9OfozQ5mCcrU03RV2IuS0C8FRombmb6H UtqVvmE0wDgoECgmJU+W5VGyceoifrKw2itrMZgfk0AV+CQ0YS5qj6IjZBt4hVwcQ2 bxXY6wRcgmRoWI5KvXmP92Zw6VlGLJ+4IwEln85pwHDYNYe9LhnLEzMeZ8HiteVGkh Tncp72lEpEXCjEcMP3E7mi8SzfLbJ3ESIio1sVgvRudfHgd8mFiLy0HNYg0EHAwQIH MPft0C8naWVrZnUe0kwwFD1GG92Gnpy/DGqKlsrKHJsjQkuKPxhMcFcNWdzcMOG+pN 63mLk5HNz7I5A== From: Marek Vasut To: u-boot@lists.denx.de Cc: trini@konsulko.com, Marek Vasut , "NXP i.MX U-Boot Team" , Fabio Estevam , Heiko Schocher , Heinrich Schuchardt , Rasmus Villemoes , Simon Glass , Stefano Babic , Ye Li Subject: [PATCH] ARM: imx: romapi: Fix signed integer bitwise ops misuse Date: Sun, 25 Jun 2023 12:34:52 +0200 Message-Id: <20230625103452.5742-1-marex@denx.de> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean Bitwise operations on signed integers are not defined, replace then with per-call checks. Signed-off-by: Marek Vasut --- Cc: "NXP i.MX U-Boot Team" Cc: Fabio Estevam Cc: Heiko Schocher Cc: Heinrich Schuchardt Cc: Rasmus Villemoes Cc: Simon Glass Cc: Stefano Babic Cc: Tom Rini Cc: Ye Li --- arch/arm/mach-imx/spl_imx_romapi.c | 32 ++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c index 9164045115f..4af41699678 100644 --- a/arch/arm/mach-imx/spl_imx_romapi.c +++ b/arch/arm/mach-imx/spl_imx_romapi.c @@ -76,13 +76,16 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, u32 image_offset; ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset); - ret |= rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize); - ret |= rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset); + if (ret != ROM_API_OKAY) + goto err; - if (ret != ROM_API_OKAY) { - puts("ROMAPI: Failure query boot infor pagesize/offset\n"); - return -1; - } + ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize); + if (ret != ROM_API_OKAY) + goto err; + + ret = rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset); + if (ret != ROM_API_OKAY) + goto err; header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR); @@ -124,6 +127,10 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image, } return 0; + +err: + puts("ROMAPI: Failure query boot infor pagesize/offset\n"); + return -1; } static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector, @@ -344,12 +351,12 @@ int board_return_to_bootrom(struct spl_image_info *spl_image, u32 boot, bstage; ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot); - ret |= rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage); + if (ret != ROM_API_OKAY) + goto err; - if (ret != ROM_API_OKAY) { - puts("ROMAPI: failure at query_boot_info\n"); - return -1; - } + ret = rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage); + if (ret != ROM_API_OKAY) + goto err; printf("Boot Stage: "); @@ -374,4 +381,7 @@ int board_return_to_bootrom(struct spl_image_info *spl_image, return spl_romapi_load_image_stream(spl_image, bootdev); return spl_romapi_load_image_seekable(spl_image, bootdev, boot); +err: + puts("ROMAPI: failure at query_boot_info\n"); + return -1; } -- 2.40.1