disk: Free volume struct on partition enumeration failure
diff --git a/common/drivers/disk.s2.c b/common/drivers/disk.s2.c
index 104bdd99..e27c67cb 100644
--- a/common/drivers/disk.s2.c
+++ b/common/drivers/disk.s2.c
@@ -348,10 +348,14 @@ void disk_create_index(void) {
struct volume *p = ext_mem_alloc(sizeof(struct volume));
int ret = part_get(p, block, part);
- if (ret == END_OF_TABLE || ret == INVALID_TABLE)
+ if (ret == END_OF_TABLE || ret == INVALID_TABLE) {
+ pmm_free(p, sizeof(struct volume));
break;
- if (ret == NO_PARTITION)
+ }
+ if (ret == NO_PARTITION) {
+ pmm_free(p, sizeof(struct volume));
continue;
+ }
volume_index = pmm_realloc(
volume_index,
