diff mbox series

[v10,6/9] bootstd: Adjust code ordering to work around compiler quirk

Message ID 20230424134946.v10.6.Id1d2749652f1e5f4cb07d1ee6f2f71983086b308@changeid
State Accepted
Commit 1aabe4ef2b746c9aa76a25787a6aef57a165ca86
Delegated to: Tom Rini
Headers show
Series bootstd: Convert rockchip and add various fixes and tweaks | expand

Commit Message

Simon Glass April 24, 2023, 1:49 a.m. UTC
At present when debugging is off, bootdev_find_in_blk() sometimes fails
to find a valid bootflow, e.g. with virtio. Accessing the 'blk' variable
later in the function seems to correct it.

Move the 'ret' check before the debug statement and set the block device
again aftewards, to work around this.

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

(no changes since v8)

Changes in v8:
- Add new patch to adjust code ordering to work around compiler quirk

 boot/bootdev-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 91087981d213..57d294464764 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -174,6 +174,8 @@  int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
 	} else {
 		ret = fs_set_blk_dev_with_part(desc, bflow->part);
 		bflow->state = BOOTFLOWST_PART;
+		if (ret)
+			return log_msg_ret("fs", ret);
 
 		/* Use an #ifdef due to info.sys_ind */
 #ifdef CONFIG_DOS_PARTITION
@@ -181,8 +183,7 @@  int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
 			  blk->name, bflow->part, info.sys_ind,
 			  ret ? -1 : fs_get_type());
 #endif
-		if (ret)
-			return log_msg_ret("fs", ret);
+		bflow->blk = blk;
 		bflow->state = BOOTFLOWST_FS;
 	}