diff options
author | Tom Rini | 2017-10-03 08:38:44 -0500 |
---|---|---|
committer | Tom Rini | 2017-10-16 08:42:51 -0500 |
commit | b351ccf11ae5616bba183aedb2c433b97123be4f (patch) | |
tree | 07571dd727b65a3e5e1dc0b8d3cadbf416b24341 /disk | |
parent | c12d8b7d70c695f1c4fe6fb4f1b3913bdbed8c96 (diff) | |
download | u-boot-b351ccf11ae5616bba183aedb2c433b97123be4f.tar.gz u-boot-b351ccf11ae5616bba183aedb2c433b97123be4f.tar.xz u-boot-b351ccf11ae5616bba183aedb2c433b97123be4f.zip |
part_efi: In is_gpt_valid() check argument validity before allocation
While this goes somewhat against normal coding style we should ensure
that dev_desc is not NULL before we dereference it in allocation of
legacy_mbr.
Reported-by: Coverity (CID: 167292)
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part_efi.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/disk/part_efi.c b/disk/part_efi.c index 0abf48733d..782f8be502 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c | |||
@@ -923,13 +923,14 @@ static int is_pmbr_valid(legacy_mbr * mbr) | |||
923 | static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba, | 923 | static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba, |
924 | gpt_header *pgpt_head, gpt_entry **pgpt_pte) | 924 | gpt_header *pgpt_head, gpt_entry **pgpt_pte) |
925 | { | 925 | { |
926 | ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz); | 926 | /* Confirm valid arguments prior to allocation. */ |
927 | |||
928 | if (!dev_desc || !pgpt_head) { | 927 | if (!dev_desc || !pgpt_head) { |
929 | printf("%s: Invalid Argument(s)\n", __func__); | 928 | printf("%s: Invalid Argument(s)\n", __func__); |
930 | return 0; | 929 | return 0; |
931 | } | 930 | } |
932 | 931 | ||
932 | ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz); | ||
933 | |||
933 | /* Read MBR Header from device */ | 934 | /* Read MBR Header from device */ |
934 | if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) { | 935 | if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) { |
935 | printf("*** ERROR: Can't read MBR header ***\n"); | 936 | printf("*** ERROR: Can't read MBR header ***\n"); |