bhyve: ahci: Fix regression with no ports

An AHCI controller may be specified with no connected ports.  Avoid
dumping core in this case for compatibility with existing VM configs.

Reviewed by:	khng, jhb
Fixes:		621b509048 Refactor configuration management in bhyve.
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision:	https://reviews.freebsd.org/D33969
This commit is contained in:
Ryan Moeller 2022-01-21 12:59:25 +00:00
parent eb815a7419
commit b252fb2430

View File

@ -2440,7 +2440,7 @@ pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl)
slots = 32;
ports_nvl = find_relative_config_node(nvl, "port");
for (p = 0; p < MAX_PORTS; p++) {
for (p = 0; ports_nvl != NULL && p < MAX_PORTS; p++) {
struct ata_params *ata_ident = &sc->port[p].ata_ident;
char ident[AHCI_PORT_IDENT];