Skip to content

Commit

Permalink
MdeModulePkg/PartitionDxe: Fix the incorrect LBA size in child hander
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2843

PartitionInstallChildHandle's parameters Start and End is counted
by the BlockSize, but in the implementation it uses the parent
device's BlockSize to calculate the new Start, End and LastBlock.
It would cause the driver report incorrect block scope and the file
system would fail to be found with right block scope.
So correct it to the right value.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Andrew Fish <afish@apple.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Tested-by: Gary Lin <glin@suse.com>
  • Loading branch information
ZhichaoGao authored and mergify[bot] committed Aug 13, 2020
1 parent 94b7df5 commit e0eacd7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,8 +1149,8 @@ PartitionInstallChildHandle (

Private->Signature = PARTITION_PRIVATE_DATA_SIGNATURE;

Private->Start = MultU64x32 (Start, ParentBlockIo->Media->BlockSize);
Private->End = MultU64x32 (End + 1, ParentBlockIo->Media->BlockSize);
Private->Start = MultU64x32 (Start, BlockSize);
Private->End = MultU64x32 (End + 1, BlockSize);

Private->BlockSize = BlockSize;
Private->ParentBlockIo = ParentBlockIo;
Expand Down Expand Up @@ -1187,13 +1187,7 @@ PartitionInstallChildHandle (

Private->Media.IoAlign = 0;
Private->Media.LogicalPartition = TRUE;
Private->Media.LastBlock = DivU64x32 (
MultU64x32 (
End - Start + 1,
ParentBlockIo->Media->BlockSize
),
BlockSize
) - 1;
Private->Media.LastBlock = End - Start;

Private->Media.BlockSize = (UINT32) BlockSize;

Expand Down

0 comments on commit e0eacd7

Please sign in to comment.