mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
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>
This commit is contained in:
parent
c12d8b7d70
commit
b351ccf11a
1 changed files with 3 additions and 2 deletions
|
@ -923,13 +923,14 @@ static int is_pmbr_valid(legacy_mbr * mbr)
|
||||||
static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
|
static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
|
||||||
gpt_header *pgpt_head, gpt_entry **pgpt_pte)
|
gpt_header *pgpt_head, gpt_entry **pgpt_pte)
|
||||||
{
|
{
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
|
/* Confirm valid arguments prior to allocation. */
|
||||||
|
|
||||||
if (!dev_desc || !pgpt_head) {
|
if (!dev_desc || !pgpt_head) {
|
||||||
printf("%s: Invalid Argument(s)\n", __func__);
|
printf("%s: Invalid Argument(s)\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
|
||||||
|
|
||||||
/* Read MBR Header from device */
|
/* Read MBR Header from device */
|
||||||
if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) {
|
if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) {
|
||||||
printf("*** ERROR: Can't read MBR header ***\n");
|
printf("*** ERROR: Can't read MBR header ***\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue