[PATCH 03/11] ARM: i.MX: bbu: Check retrun value of getenv()

Andrey Smirnov andrew.smirnov at gmail.com
Tue Sep 18 15:22:57 PDT 2018


Add code to make sure that getenv() returned correct result and bail
out if it failed.

Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 697e59f12..faa266572 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -415,6 +415,11 @@ static int imx_bbu_internal_mmcboot_update(struct bbu_handler *handler,
 		return ret;
 
 	bootpart = getenv(bootpartvar);
+	if (!bootpart) {
+		pr_err("Couldn't read the value of '%s'\n", bootpartvar);
+		ret = -ENOENT;
+		goto free_bootpartvar;
+	}
 
 	if (!strcmp(bootpart, "boot0")) {
 		bootpart = "boot1";
-- 
2.17.1




More information about the barebox mailing list