Skip to content

Commit 64a11fb

Browse files
makohoektrini
authored andcommittedOct 22, 2022
cmd: bcb: select user(0) hwpart in __bcb_load()
For some blk operations, it's possible that a different hw partition gets selected via blk_dselect_hwpart(). In that case, only the region of the device covered by that partition is accessible. This breaks "bcb load" which attempts to read the gpt and assumes it's on the user(0) hw partition: => bcb load 2 misc GUID Partition Table Header signature is wrong: 0xDE7B17AD07D9E5D6 != 0x5452415020494645 find_valid_gpt: *** ERROR: Invalid GPT *** GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645 find_valid_gpt: *** ERROR: Invalid Backup GPT *** Error: mmc 2:misc read failed (-2) Add a fail-safe in __bcb_load() to ensure we will always read from the user(0) hwpartition. This fixes the following fastboot sequence: $ fastboot erase mmc2boot1 # switch to hwpart1 $ fastboot reboot bootloader # switch to hwpart0, then reads GPT Signed-off-by: Mattijs Korpershoek <[email protected]> Reviewed-by: Sean Anderson <[email protected]>
1 parent 65e8b64 commit 64a11fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎cmd/bcb.c

+11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <part.h>
1515
#include <malloc.h>
1616
#include <memalign.h>
17+
#include <linux/err.h>
1718

1819
enum bcb_cmd {
1920
BCB_CMD_LOAD,
@@ -128,6 +129,16 @@ static int __bcb_load(int devnum, const char *partp)
128129
goto err_read_fail;
129130
}
130131

132+
/*
133+
* always select the USER mmc hwpart in case another
134+
* blk operation selected a different hwpart
135+
*/
136+
ret = blk_dselect_hwpart(desc, 0);
137+
if (IS_ERR_VALUE(ret)) {
138+
ret = -ENODEV;
139+
goto err_read_fail;
140+
}
141+
131142
part = simple_strtoul(partp, &endp, 0);
132143
if (*endp == '\0') {
133144
ret = part_get_info(desc, part, &info);

0 commit comments

Comments
 (0)
Please sign in to comment.