All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>,
	Guillaume La Roque <glaroque@baylibre.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Tom Rini <trini@konsulko.com>
Subject: [PATCH 2/5] test: bootflow: Avoid a confusing error condition
Date: Thu, 19 Dec 2024 21:01:17 -0700	[thread overview]
Message-ID: <20241220040120.3245610-3-sjg@chromium.org> (raw)
In-Reply-To: <20241220040120.3245610-1-sjg@chromium.org>

The prep_mmc_bootdev() function replaces bootstd's bootdev_order with
its own static version, then returns it.

From then on std->bootdev_order cannot be freed, since it was not
allocated.

So long as the test passes, all is well. But if a test fails, the test
system will try to free std->bootdev_order and this will fail.

Adjust prep_mmc_bootdev() to allocate the boot_dev order, instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/boot/bootflow.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 35580cee90c..4d7d795cbe1 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -540,12 +540,15 @@ BOOTSTD_TEST(bootflow_cmd_boot, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE);
 static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
 			    bool bind_cros_android, const char ***old_orderp)
 {
-	static const char *order[] = {"mmc2", "mmc1", NULL, NULL};
+	static const char **order;
 	struct udevice *dev, *bootstd;
 	struct bootstd_priv *std;
 	const char **old_order;
 	ofnode root, node;
 
+	order = calloc(sizeof(void *), 4);
+	order[0] = "mmc2";
+	order[1] = "mmc1";
 	order[2] = mmc_dev;
 
 	/* Enable the requested mmc node since we need a second bootflow */
@@ -605,6 +608,7 @@ static int scan_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
 	/* Restore the order used by the device tree */
 	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
 	std = dev_get_priv(bootstd);
+	free(std->bootdev_order);
 	std->bootdev_order = old_order;
 
 	return 0;
@@ -635,6 +639,7 @@ static int scan_mmc_android_bootdev(struct unit_test_state *uts, const char *mmc
 	/* Restore the order used by the device tree */
 	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
 	std = dev_get_priv(bootstd);
+	free(std->bootdev_order);
 	std->bootdev_order = old_order;
 
 	return 0;
@@ -726,6 +731,7 @@ static int bootflow_scan_menu(struct unit_test_state *uts)
 
 	std->bootdev_order = new_order; /* Blue Monday */
 	ut_assertok(run_command("bootflow scan -lm", 0));
+	free(std->bootdev_order);
 	std->bootdev_order = old_order;
 
 	ut_assertnull(std->cur_bootflow);
-- 
2.34.1


  parent reply	other threads:[~2024-12-20  4:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20  4:01 [PATCH 0/5] pxe: Support an automatic localboot Simon Glass
2024-12-20  4:01 ` [PATCH 1/5] test/py: Refactor extlinux-image creation into a function Simon Glass
2024-12-20  4:01 ` Simon Glass [this message]
2024-12-20  4:01 ` [PATCH 3/5] pxe_utils: Allow the FDT to be missing Simon Glass
2024-12-20 14:45   ` Tom Rini
2025-01-14 15:13   ` Quentin Schulz
2025-01-15  1:16     ` Simon Glass
2025-01-15 11:59       ` Quentin Schulz
2025-01-15 13:19         ` Simon Glass
2024-12-20  4:01 ` [PATCH 4/5] pxe_utils: Support a backup for localboot Simon Glass
2024-12-20 14:56   ` Tom Rini
2024-12-20 17:18     ` Simon Glass
2024-12-20 17:23       ` Tom Rini
2024-12-20 17:37         ` Simon Glass
2024-12-20 20:48           ` Tom Rini
2025-01-08 17:04             ` Simon Glass
2025-01-08 17:31               ` Tom Rini
2025-01-09 12:31                 ` Simon Glass
2024-12-20  4:01 ` [PATCH 5/5] pxe_utils: Support the SAY command Simon Glass
2024-12-20 14:44   ` Tom Rini
2024-12-20 17:36     ` Simon Glass
2024-12-20 18:30       ` Tom Rini
2024-12-20 19:34         ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220040120.3245610-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=glaroque@baylibre.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=mkorpershoek@baylibre.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.