diff options
author | Alexander Graf <agraf@suse.de> | 2016-08-05 14:51:47 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-08-08 13:33:00 -0400 |
commit | 0812d1a094c402db4fc25ca988113a6d6663c70f (patch) | |
tree | 137a50d9ecc5a3a36614647c0e63b178c02b9cf4 | |
parent | f9d334bdfce2358c6eada4138a2102afc46fb124 (diff) | |
download | u-boot-imx-0812d1a094c402db4fc25ca988113a6d6663c70f.zip u-boot-imx-0812d1a094c402db4fc25ca988113a6d6663c70f.tar.gz u-boot-imx-0812d1a094c402db4fc25ca988113a6d6663c70f.tar.bz2 |
efi_loader: disk: Sanitize exposed devices
When a target device is 0 bytes long, there's no point in exposing it to
the user. Let's just skip them.
Also, when an offset is passed into the efi disk creation, we should
remove this offset from the total number of sectors we can handle.
This patch fixes both things.
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | lib/efi_loader/efi_disk.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index e00a747..d8ddcc9 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -202,6 +202,10 @@ static void efi_disk_add_dev(const char *name, struct efi_device_path_file_path *dp; int objlen = sizeof(*diskobj) + (sizeof(*dp) * 2); + /* Don't add empty devices */ + if (!desc->lba) + return; + diskobj = calloc(1, objlen); /* Fill in object data */ @@ -221,7 +225,7 @@ static void efi_disk_add_dev(const char *name, diskobj->media.media_present = 1; diskobj->media.block_size = desc->blksz; diskobj->media.io_align = desc->blksz; - diskobj->media.last_block = desc->lba; + diskobj->media.last_block = desc->lba - offset; diskobj->ops.media = &diskobj->media; /* Fill in device path */ |