aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/efi.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/partitions/efi.c')
-rw-r--r--fs/partitions/efi.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 1bea610078b3..e7b07006bc41 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -152,7 +152,7 @@ last_lba(struct block_device *bdev)
152} 152}
153 153
154static inline int 154static inline int
155pmbr_part_valid(struct partition *part, u64 lastlba) 155pmbr_part_valid(struct partition *part)
156{ 156{
157 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT && 157 if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
158 le32_to_cpu(part->start_sect) == 1UL) 158 le32_to_cpu(part->start_sect) == 1UL)
@@ -163,7 +163,6 @@ pmbr_part_valid(struct partition *part, u64 lastlba)
163/** 163/**
164 * is_pmbr_valid(): test Protective MBR for validity 164 * is_pmbr_valid(): test Protective MBR for validity
165 * @mbr: pointer to a legacy mbr structure 165 * @mbr: pointer to a legacy mbr structure
166 * @lastlba: last_lba for the whole device
167 * 166 *
168 * Description: Returns 1 if PMBR is valid, 0 otherwise. 167 * Description: Returns 1 if PMBR is valid, 0 otherwise.
169 * Validity depends on two things: 168 * Validity depends on two things:
@@ -171,13 +170,13 @@ pmbr_part_valid(struct partition *part, u64 lastlba)
171 * 2) One partition of type 0xEE is found 170 * 2) One partition of type 0xEE is found
172 */ 171 */
173static int 172static int
174is_pmbr_valid(legacy_mbr *mbr, u64 lastlba) 173is_pmbr_valid(legacy_mbr *mbr)
175{ 174{
176 int i; 175 int i;
177 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE) 176 if (!mbr || le16_to_cpu(mbr->signature) != MSDOS_MBR_SIGNATURE)
178 return 0; 177 return 0;
179 for (i = 0; i < 4; i++) 178 for (i = 0; i < 4; i++)
180 if (pmbr_part_valid(&mbr->partition_record[i], lastlba)) 179 if (pmbr_part_valid(&mbr->partition_record[i]))
181 return 1; 180 return 1;
182 return 0; 181 return 0;
183} 182}
@@ -516,7 +515,7 @@ find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
516 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0; 515 int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
517 gpt_header *pgpt = NULL, *agpt = NULL; 516 gpt_header *pgpt = NULL, *agpt = NULL;
518 gpt_entry *pptes = NULL, *aptes = NULL; 517 gpt_entry *pptes = NULL, *aptes = NULL;
519 legacy_mbr *legacymbr = NULL; 518 legacy_mbr *legacymbr;
520 u64 lastlba; 519 u64 lastlba;
521 if (!bdev || !gpt || !ptes) 520 if (!bdev || !gpt || !ptes)
522 return 0; 521 return 0;
@@ -528,9 +527,8 @@ find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
528 if (legacymbr) { 527 if (legacymbr) {
529 read_lba(bdev, 0, (u8 *) legacymbr, 528 read_lba(bdev, 0, (u8 *) legacymbr,
530 sizeof (*legacymbr)); 529 sizeof (*legacymbr));
531 good_pmbr = is_pmbr_valid(legacymbr, lastlba); 530 good_pmbr = is_pmbr_valid(legacymbr);
532 kfree(legacymbr); 531 kfree(legacymbr);
533 legacymbr=NULL;
534 } 532 }
535 if (!good_pmbr) 533 if (!good_pmbr)
536 goto fail; 534 goto fail;