From 6f7cfa9511abbf4898afea576821cae9c1246087 Mon Sep 17 00:00:00 2001 From: cg Date: Sun, 25 Mar 2001 19:09:06 +0000 Subject: release resources if one of the speculative probes in opti_detect() fails, otherwise resource_list_alloc panics when opti_detect tries its next probe. --- sys/dev/sound/isa/mss.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sys') diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c index 6cf53cf..25ef24d 100644 --- a/sys/dev/sound/isa/mss.c +++ b/sys/dev/sound/isa/mss.c @@ -289,6 +289,11 @@ mss_release_resources(struct mss_info *mss, device_t dev) mss->conf_base); mss->conf_base = 0; } + if (mss->indir) { + bus_release_resource(dev, SYS_RES_IOPORT, mss->indir_rid, + mss->indir); + mss->indir = 0; + } if (mss->parent_dmat) { bus_dma_tag_destroy(mss->parent_dmat); mss->parent_dmat = 0; @@ -1339,7 +1344,6 @@ mss_detect(device_t dev, struct mss_info *mss) name = "AD1848"; mss->bd_id = MD_AD1848; /* AD1848 or CS4248 */ - if (opti_detect(dev, mss)) { switch (mss->bd_id) { case MD_OPTI924: @@ -1592,6 +1596,13 @@ opti_detect(device_t dev, struct mss_info *mss) if (opti_read(mss, 1) != 0xff) { return 1; + } else { + if (mss->indir) + bus_release_resource(dev, SYS_RES_IOPORT, mss->indir_rid, mss->indir); + mss->indir = NULL; + if (mss->conf_base) + bus_release_resource(dev, SYS_RES_IOPORT, mss->conf_rid, mss->conf_base); + mss->conf_base = NULL; } } return 0; @@ -2046,12 +2057,6 @@ opti_init(device_t dev, struct mss_info *mss) device_set_flags(dev, device_get_flags(dev) | DV_F_TRUE_MSS); - if (mss->indir) { - bus_release_resource(dev, SYS_RES_IOPORT, mss->indir_rid, - mss->indir); - mss->indir_rid = -1; - } - return 0; } -- cgit v1.1