Instead of unconditional dereferencing of pointers that may be NULL, do a controlled panic in the case we are out of memory by using xmalloc(). Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- common/partitions/dos.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 8e4edd885bfa..511d58cf0489 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -53,7 +53,7 @@ static inline int is_extended_partition(struct partition *p) static void *read_mbr(struct block_device *blk) { - void *buf = malloc(SECTOR_SIZE); + void *buf = xmalloc(SECTOR_SIZE); int ret; ret = block_read(blk, buf, 0, 1); @@ -124,7 +124,7 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv) static void dos_extended_partition(struct block_device *blk, struct dos_partition_desc *dpd, struct partition *partition, uint32_t signature) { - uint8_t *buf = malloc(SECTOR_SIZE); + uint8_t *buf = xmalloc(SECTOR_SIZE); uint32_t ebr_sector = partition->first_sec; struct partition_entry *table = (struct partition_entry *)&buf[0x1be]; unsigned partno = 4; -- 2.39.5