diff options
author | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2023-08-26 03:53:42 +0200 |
---|---|---|
committer | Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | 2023-08-27 08:21:07 +0200 |
commit | 41cd23b7be6e097daa5c2b1eda5539de227bf745 (patch) | |
tree | 46bbe0e1d6384a30f2d7096284cfae23dadc4e91 /cmd/gpt.c | |
parent | 018346770b04e32caf75d5730301f3ba52ed005f (diff) | |
download | u-boot-41cd23b7be6e097daa5c2b1eda5539de227bf745.tar.gz u-boot-41cd23b7be6e097daa5c2b1eda5539de227bf745.tar.bz2 u-boot-41cd23b7be6e097daa5c2b1eda5539de227bf745.zip |
cmd: fix gpt enumerate
Do not assume that partitions are numbered continuously starting at 1.
Only a single partition table type can exist on a block device. If we found
a GPT partition table, we must not re-enumerate with the MBR partition
driver which would find the protective partition.
Fixes: 12fc1f3bb223 ("cmd: gpt: add eMMC and GPT support")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd/gpt.c')
-rw-r--r-- | cmd/gpt.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -691,12 +691,13 @@ static int gpt_enumerate(struct blk_desc *desc) int ret; int i; + if (part_drv->test(desc)) + continue; + for (i = 1; i < part_drv->max_entries; i++) { ret = part_drv->get_info(desc, i, &pinfo); - if (ret) { - /* no more entries in table */ - break; - } + if (ret) + continue; ptr = &part_list[str_len]; tmp_len = strlen((const char *)pinfo.name); @@ -711,9 +712,10 @@ static int gpt_enumerate(struct blk_desc *desc) /* One byte for space(" ") delimiter */ ptr[tmp_len] = ' '; } + if (*part_list) + part_list[strlen(part_list) - 1] = 0; + break; } - if (*part_list) - part_list[strlen(part_list) - 1] = 0; debug("setenv gpt_partition_list %s\n", part_list); return env_set("gpt_partition_list", part_list); |