Skip to contentSkip to conversation

disk: part_dos: fix part_get_info_extended() function

PATCH In review Shawn Guo 2 participants 2 messages Nov 2, 2017 – Nov 6, 2017

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/1 disk: part_dos: fix part_get_info_extended() function

From: Shawn Guo <[email protected]>

The check in part_get_info_extended() for a successful partition searching misses a condition for extended partition. In case of (ext_part_sector == 0), we should anyway mark the partition as found, even if it's an extended partition, i.e. (is_extended(pt->sys_ind) == 0). Otherwise, the extended partition (type 0x0f) will never be identified, and the following recursive call to part_get_info_extended() will get a wrong 'part_num' and 'which_part' parameter. In the end, all those partitions in extended table will not be identified.

Let's add the missing OR condition of (ext_part_sector == 0) for is_extended() check to fix the problem.

The issue is discovered by running fastboot flash to an extended partition on eMMC.

  $ fastboot flash mmcsda5 cache.img
  target reported max download size of 536870912 bytes
  sending 'mmcsda5' (18796 KB)...
  OKAY [  2.144s]
  writing 'mmcsda5'...
  FAILED (remote: cannot find partition)
  finished. total time: 2.261s
---
 disk/part_dos.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
disk/part_dos.c +1 -1
index 1a36be0446ac..4485eb704852 100644
@@ -210,7 +210,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc,
 		if (((pt->boot_ind & ~0x80) == 0) &&
 		    (pt->sys_ind != 0) &&
 		    (part_num == which_part) &&
-		    (is_extended(pt->sys_ind) == 0)) {
+		    (ext_part_sector == 0 || is_extended(pt->sys_ind) == 0)) {
 			info->blksz = DOS_PART_DEFAULT_SECTOR;
 			info->start = (lbaint_t)(ext_part_sector +
 					le32_to_int(pt->start4));
Signature · 1 line
1.9.1
#1 lore raw
Quoted 25 lines · Shawn Guo

From: Shawn Guo <[email protected]>

The check in part_get_info_extended() for a successful partition searching misses a condition for extended partition. In case of (ext_part_sector == 0), we should anyway mark the partition as found, even if it's an extended partition, i.e. (is_extended(pt->sys_ind) == 0). Otherwise, the extended partition (type 0x0f) will never be identified, and the following recursive call to part_get_info_extended() will get a wrong 'part_num' and 'which_part' parameter. In the end, all those partitions in extended table will not be identified.

Let's add the missing OR condition of (ext_part_sector == 0) for is_extended() check to fix the problem.

The issue is discovered by running fastboot flash to an extended partition on eMMC.

  $ fastboot flash mmcsda5 cache.img
  target reported max download size of 536870912 bytes
  sending 'mmcsda5' (18796 KB)...
  OKAY [  2.144s]
  writing 'mmcsda5'...
  FAILED (remote: cannot find partition)
  finished. total time: 2.261s
Quoted 1 line

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171106/da39ae5b/attachment.sig>