[PATCH] partitions/efi: Fix off-by-one error in 'last_lba'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



LBAs are numbered starting from zero so the last LBA # would be equal
to total number of blocks minus one.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/partitions/efi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index dcb9541..80dc3f3 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -51,11 +51,11 @@ efi_crc32(const void *buf, unsigned long len)
  *  the part[0] entry for this disk, and is the number of
  *  physical sectors available on the disk.
  */
-static u64 last_lba(struct block_device *bdev)
+static u64  last_lba(struct block_device *bdev)
 {
 	if (!bdev)
 		return 0;
-	return bdev->num_blocks;
+	return bdev->num_blocks - 1;
 }
 
 /**
-- 
1.9.3


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux