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 5B35FC7EE23 for ; Wed, 1 Mar 2023 23:38:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5F02985B67; Thu, 2 Mar 2023 00:38:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PKRXH+w7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 25E1F85720; Thu, 2 Mar 2023 00:38:38 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 40C5C85720 for ; Thu, 2 Mar 2023 00:38:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ed1-x536.google.com with SMTP id d30so60793674eda.4 for ; Wed, 01 Mar 2023 15:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XG+Bk/1hhV8uMBdy/zOtkmLrSX0lhD7EfvSZ2k+mpmw=; b=PKRXH+w7AEimpa+7fg6fzCRHSvMxB+1+Jl5W/L6zAEbf/15wl6U8v1J2lXaj++IA5a vDepvJah4oKMyTrjHzTn9LaVyXPXR5VZq8/ysIH8AmK5Ipl3FcIVEJXtWU8m2DTOtuG3 2chfBAJzDqflSC/S7NEFefGLJFGRzP5/w+FbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XG+Bk/1hhV8uMBdy/zOtkmLrSX0lhD7EfvSZ2k+mpmw=; b=fofrh2jwz6avlY/Zo3ruVCa00y8RClUpz5k/r+iWnAFNZwr+0bw1kWEhRK7lYw+w3x wD+t0b5VvKDmMGQw401/vBqP/+ZBhh/CTPsMoDf1znHq0J5S7SlEunsnoYJJuQq5ywzm Cmz9gDLjXWij4yhFuusLJACOwZ4fAJdKKl7+s6hr3CRYC47YiU0xPGdNeVM7vLAs9ImJ 7f74bQb3Nyyx+IqQ5Xb16DEamekk93naDW8a2zl6gUdnbFwHB1n7TpL6xZ+lzun96Mvz yuep/HMCWfCNAdWcGx2U/2MKoZvSrRV5Sm3NUtSKK8J2V00ii3ibxuS/9KS79wCWcC/5 0AAw== X-Gm-Message-State: AO0yUKWctNn38voQuvECtRoECr3dAZKgDShuPbxR2aLC4eYp9bftMji4 FuZsOnNVtjwdpIdpRdDPTCfe1u+4ublgEnsEhINQkA== X-Google-Smtp-Source: AK7set8o2mmzz5T/ATI2XrTIdKYMnatgWBzx569FfygmijG3O90JoLvMxPGhlSqOBEP97idpGv11E3HR3jCtSU60Nrg= X-Received: by 2002:a17:906:e213:b0:8b1:7682:3181 with SMTP id gf19-20020a170906e21300b008b176823181mr3853411ejb.9.1677713914394; Wed, 01 Mar 2023 15:38:34 -0800 (PST) MIME-Version: 1.0 References: <20230227195631.98868-1-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195631.98868-1-marek.vasut+renesas@mailbox.org> From: Simon Glass Date: Wed, 1 Mar 2023 16:38:22 -0700 Message-ID: Subject: Re: [PATCH] image: Fix potentially uninitialized data variable To: Marek Vasut Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Michal Simek , Oleksandr Suvorov , Stefan Roese , Tom Rini Content-Type: text/plain; charset="UTF-8" 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.6 at phobos.denx.de X-Virus-Status: Clean On Mon, 27 Feb 2023 at 12:56, Marek Vasut wrote: > > In case fitImage support is disabled, and image_locate_script() is > passed a fitImage, then the 'data' variable is used uninitialized. > Drop into the default: branch of the switch-case statement and do > not return the uninitialized data, and do not modify the return > pointer either, just print an error message. > > Reported by clang build: > " > $ make HOSTCC=clang CC=clang KCFLAGS=-Werror sandbox64_defconfig && make HOSTCC=clang CC=clang KCFLAGS=-Werror > ... > boot/image-board.c:1006:7: error: variable 'data' is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized] > case IMAGE_FORMAT_LEGACY: > ^~~~~~~~~~~~~~~~~~~ > include/image.h:608:29: note: expanded from macro 'IMAGE_FORMAT_LEGACY' > ^~~~ > boot/image-board.c:1128:19: note: uninitialized use occurs here > *datap = (char *)data; > ^~~~ > boot/image-board.c:1001:11: note: initialize the variable 'data' to silence this warning > u32 *data; > ^ > = NULL > " > > Signed-off-by: Marek Vasut > --- > Cc: Heinrich Schuchardt > Cc: Michal Simek > Cc: Oleksandr Suvorov > Cc: Simon Glass > Cc: Stefan Roese > Cc: Tom Rini > --- > boot/image-board.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > Reviewed-by: Simon Glass