]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Allow last block to be read
authorJesper Schmitz Mouridsen <jesper@schmitz.computer>
Tue, 9 Feb 2021 16:17:17 +0000 (17:17 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 21 Feb 2021 08:21:35 +0000 (09:21 +0100)
The last block is of size media->block_size

Signed-off-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer>
Simplify expression.
Apply same change to efi_disk_write_blocks().

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
lib/efi_loader/efi_disk.c

index 1f6b817deadfa3f6b35d9b8b5127bbff5816fb2c..307d5d759b8c1b87c27c6a04148e40db50ceadf5 100644 (file)
@@ -148,7 +148,7 @@ static efi_status_t EFIAPI efi_disk_read_blocks(struct efi_block_io *this,
            (uintptr_t)buffer & (this->media->io_align - 1))
                return EFI_INVALID_PARAMETER;
        if (lba * this->media->block_size + buffer_size >
-           this->media->last_block * this->media->block_size)
+           (this->media->last_block + 1) * this->media->block_size)
                return EFI_INVALID_PARAMETER;
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
@@ -216,7 +216,7 @@ static efi_status_t EFIAPI efi_disk_write_blocks(struct efi_block_io *this,
            (uintptr_t)buffer & (this->media->io_align - 1))
                return EFI_INVALID_PARAMETER;
        if (lba * this->media->block_size + buffer_size >
-           this->media->last_block * this->media->block_size)
+           (this->media->last_block + 1) * this->media->block_size)
                return EFI_INVALID_PARAMETER;
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER