From 2a4eff4703c548402ea6d5444ef8878d15cada46 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 8 Jun 2009 15:07:35 +0000 Subject: [PATCH] Don't attempt to free the GPT partition list for a disk with an empty GPT. Submitted by: Yuri Pankov yuri.pankov of gmail MFC after: 3 days --- sys/boot/i386/libi386/biosdisk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/boot/i386/libi386/biosdisk.c b/sys/boot/i386/libi386/biosdisk.c index 84b58d6c555c..b49d4e6ec855 100644 --- a/sys/boot/i386/libi386/biosdisk.c +++ b/sys/boot/i386/libi386/biosdisk.c @@ -990,7 +990,8 @@ bd_open_gpt(struct open_disk *od, struct i386_devdesc *dev) out: if (error) { - free(od->od_partitions); + if (od->od_nparts > 0) + free(od->od_partitions); od->od_flags &= ~BD_GPTOK; } return (error); @@ -1044,7 +1045,7 @@ bd_closedisk(struct open_disk *od) delay(3000000); #endif #ifdef LOADER_GPT_SUPPORT - if (od->od_flags & BD_GPTOK) + if (od->od_flags & BD_GPTOK && od->od_nparts > 0) free(od->od_partitions); #endif free(od);