From patchwork Fri Jan 19 21:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 763953 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp77761wrx; Fri, 19 Jan 2024 13:33:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IG97Tu7Lvra9K0RNC5pa4oL24kLM++S/JZNqxYLER2H5Q8UHNDT06DuDxarwURCyPB3pwVf X-Received: by 2002:a05:6000:189:b0:337:c91d:e819 with SMTP id p9-20020a056000018900b00337c91de819mr178168wrx.48.1705699996322; Fri, 19 Jan 2024 13:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705699996; cv=none; d=google.com; s=arc-20160816; b=u7LQKKCria/4QAMll9k3F2sCgPRgAdJjE0e095vsGYRE/DjMGsiN+Ym58SKCw/K2uf lb1xu38OlJZy2LymIyKn4aczjBXqH42vk8SsNvRo84wNMVNyO7UNWVVd/9Pfoqfjj83u N7ZLtRIEpkzwcgSg/Vs076EFNL+GxrFpu7dtPomM5Dyst0wVtHE9CCz2OCVOeLBGgomb JpIg7dxkQ/K3E0yf3EuzInFeD9HVO/mAZdijHQgPxTzbzVWOTTWk4PjPkj+xVRF2lzd1 XvYLKY1ElNNBRBBJmpcthp9aarjT2QWEGO26cyZg6rGCOrSCsnwiNd6emrm75c/z/jDq BicQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Q9Irad7bq9Na7d+aOFd0r7sLjoV9DLczJTXO97vMqPg=; fh=py1ULPoZdaFlPwx8HNH9yThZWWOzdTeFoU/9xOTva64=; b=oAxFF9oLNa2N3gaPAn5VK1ma6OlZK0esh9EFAly23AYUIdpie3C8obCyK6vSWhor4l dYNgwkXLkUzfns/5+smURxnPpefdBJGGZ4sZN9txyiZtppAIRshomZ2d5/AfjHeVG7uw jVKaZwRbvIbuwynd47WA8Q3bJuSEBD4bmYVvPvmKc5qgjV0MLOjb706IrdVFI1L13NAa 3RmcTm1N1UGC5KUU/7qC+9lW+Gk0Adb+GcE91cFpS+ezZ8WqqwvrIqDxwwFHOTI+2xpf XYAi+ZPtwceYkhalFTHUAqHgpqr2AmuBSIGgkzq7AfzM62TFo81uyeerjoFewVL2mk63 bt7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KmEurgHP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id h3-20020a5d5043000000b003365c0b7577si3744997wrt.456.2024.01.19.13.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 13:33:16 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KmEurgHP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20E6687A2A; Fri, 19 Jan 2024 22:33:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="KmEurgHP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4E2EE87A2A; Fri, 19 Jan 2024 22:33:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) (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 2FA8687920 for ; Fri, 19 Jan 2024 22:33:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ralph.siemsen@linaro.org Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-6817a470730so6041596d6.3 for ; Fri, 19 Jan 2024 13:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705699990; x=1706304790; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q9Irad7bq9Na7d+aOFd0r7sLjoV9DLczJTXO97vMqPg=; b=KmEurgHPC8BgEGvLkFnx9b7yBUfXRwVBDKBT+wIGcR7CIsLcUmhRsRlagNccDQTzkB 6ymLrS/RNzoxD1E55QEZNzHPq6zqfiR/HPi9kro0Scnkjm0t/y4bKNiQ0red9DA+kSaC TXr61qYgqiqDYwkeTr9wwNa87YMCkwdo1UrOnd5IDzbyphACm2UyYKOVGerFz4VaopMq 1CmbAyZnNEfxz2RdjcmNA2d3uQhRfzLlW7BTOYhJM2JY1n4BzmdYeikHnfSBaIQbDgpL 1JPxy50UZtdMcVMgf16pjuzdjU3Kb/GGnDrWhOBaJqOp0T0AnUtkDsN8KKk4DWQTwT3V 0smA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705699990; x=1706304790; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Q9Irad7bq9Na7d+aOFd0r7sLjoV9DLczJTXO97vMqPg=; b=jeTIwy+6V9DR+LtMz5/5/rEP8DdnUMvOEz2BGMLs1a9pPFa2r5clk14gUp1ca+DDRp Z6uQJyGb43AEni3aDPtxbivbOHtlKIGd7OB7QwXaHw3/GIRxOSDlHMefLBEJlK+GzONo Mtp83DXM2U2nStWylcrKgFtWkg2NVw6wnQPr3dKxY4FabIcHa8RN0kUPWHkovovDlcG6 RIhjsBC5w2oRqyjmoKTZXLhPn77+5vGrgY10Y8gHi2ZE8uP47FCsfdRVctlsnKAYJODi cPLIbx1ygnaOMMmS0nKO3Oi8eyxt82Tuc1jumHfcoWLiCkEEMzEi1UKB4Txjs4FXdAsS AtCw== X-Gm-Message-State: AOJu0YyXTmIulr/8jKMvyQ2f8QBrTGqWzZRv8w1Wq3yqFwAZeJgamPBo mHba9YCieUwcVxS4yLK9uRhF+BZY+3Q9o+tYP3YHYJEWwUddsq83E0bBjQQMpQ4= X-Received: by 2002:ad4:5ecd:0:b0:681:7ba3:3649 with SMTP id jm13-20020ad45ecd000000b006817ba33649mr656721qvb.63.1705699989923; Fri, 19 Jan 2024 13:33:09 -0800 (PST) Received: from maple.home ([70.51.77.95]) by smtp.gmail.com with ESMTPSA id l15-20020ad44bcf000000b00684d962f0acsm39147qvw.83.2024.01.19.13.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 13:33:09 -0800 (PST) From: Ralph Siemsen To: joe.hershberger@ni.com, u-boot@lists.denx.de Cc: Ralph Siemsen Subject: [PATCH] env: sf: report malloc error to caller Date: Fri, 19 Jan 2024 16:32:17 -0500 Message-Id: <20240119213216.3811402-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 In the non-redundant code for env_sf_save(), a failure to malloc() the temporary buffer produces the following output: Saving Environment to SPIFlash... OK This is misleading as the flash has neither been erased nor written. Fix it to return an error to the caller, so the output will be: Saving Environment to SPIFlash... Failed (-12) Note that there is another copy of env_sf_save() in the same file, for handling redundant environment, and it already has the same logic. Signed-off-by: Ralph Siemsen --- env/sf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/env/sf.c b/env/sf.c index a425ecc11c8..8f5c03b00d3 100644 --- a/env/sf.c +++ b/env/sf.c @@ -210,8 +210,10 @@ static int env_sf_save(void) saved_size = sect_size - CONFIG_ENV_SIZE; saved_offset = CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE; saved_buffer = malloc(saved_size); - if (!saved_buffer) + if (!saved_buffer) { + ret = -ENOMEM; goto done; + } ret = spi_flash_read(env_flash, saved_offset, saved_size, saved_buffer);