PR 56310: avoid assert() failures (or crashes) when the runtime addition

of a wedge fails (for whatever reasons).
This commit is contained in:
martin 2021-07-17 11:32:50 +00:00
parent f71e925086
commit 2f5e5e5d38
2 changed files with 14 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: gpt.c,v 1.23 2021/01/31 22:45:46 rillig Exp $ */
/* $NetBSD: gpt.c,v 1.24 2021/07/17 11:32:50 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@ -1404,8 +1404,11 @@ gpt_get_part_device(const struct disk_partitions *arg,
usage = plain_name;
if (usage == plain_name || usage == raw_dev_name)
life = true;
if (!(p->gp_flags & GPEF_WEDGE) && life)
gpt_add_wedge(arg->disk, p);
if (!(p->gp_flags & GPEF_WEDGE) && life &&
!gpt_add_wedge(arg->disk, p)) {
devname[0] = 0;
return false;
}
switch (usage) {
case logical_name:

View File

@ -1,4 +1,4 @@
/* $NetBSD: partman.c,v 1.51 2021/01/31 22:45:46 rillig Exp $ */
/* $NetBSD: partman.c,v 1.52 2021/07/17 11:32:50 martin Exp $ */
/*
* Copyright 2012 Eugene Lozovoy
@ -2847,13 +2847,13 @@ pm_menufmt(menudesc *m, int opt, void *arg)
dev_status);
break;
case PM_PART:
if (parts->pscheme->get_part_device != NULL)
parts->pscheme->get_part_device(
parts, part_num,
dev, sizeof dev, NULL, plain_name, false,
true);
else
strcpy(dev, "-");
if (parts->pscheme->get_part_device == NULL ||
!parts->pscheme->get_part_device(
parts, part_num,
dev, sizeof dev, NULL, plain_name, false,
true))
strcpy(dev, "-");
parts->pscheme->get_part_info(parts,
part_num, &info);
if (pm_cur->mounted != NULL &&