summaryrefslogtreecommitdiffstats
path: root/sys/pc98
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2000-04-22 15:12:52 +0000
committernyan <nyan@FreeBSD.org>2000-04-22 15:12:52 +0000
commit6697052cf1bac791dd12d2e55626ebc0f97699a8 (patch)
tree190e17540a99ebee7e5a3370b3a09a9ae292ad54 /sys/pc98
parent494d7321f02ecd2732e6365ca8670bfb8f3688f3 (diff)
downloadFreeBSD-src-6697052cf1bac791dd12d2e55626ebc0f97699a8.zip
FreeBSD-src-6697052cf1bac791dd12d2e55626ebc0f97699a8.tar.gz
Release allocated resources and return ENXIO on error.
Diffstat (limited to 'sys/pc98')
-rw-r--r--sys/pc98/cbus/sio.c23
-rw-r--r--sys/pc98/pc98/sio.c23
2 files changed, 32 insertions, 14 deletions
diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c
index 492b7ee..2cce636729 100644
--- a/sys/pc98/cbus/sio.c
+++ b/sys/pc98/cbus/sio.c
@@ -1244,8 +1244,10 @@ sioprobe(dev, xrid)
/*
* If the port is i8251 UART (internal, B98_01)
*/
- if (pc98_check_if_type(dev, &iod) == -1)
+ if (pc98_check_if_type(dev, &iod) == -1) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return (ENXIO);
+ }
if (iod.irq > 0)
bus_set_resource(dev, SYS_RES_IRQ, 0, iod.irq, 1);
if (IS_8251(iod.if_type)) {
@@ -1334,14 +1336,18 @@ sioprobe(dev, xrid)
mcr_image = 0;
rsabase = iobase & 0xfff0;
- if (rsabase != iobase)
- return(0);
+ if (rsabase != iobase) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
+ }
iobase += 8;
outb(rsabase + rsa_msr, 0x04);
outb(rsabase + rsa_frr, 0x00);
- if ((inb(rsabase + rsa_srr) & 0x36) != 0x36)
- return (0);
+ if ((inb(rsabase + rsa_srr) & 0x36) != 0x36) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
+ }
outb(rsabase + rsa_ier, 0x00);
outb(rsabase + rsa_frr, 0x00);
outb(rsabase + rsa_tivsr, 0x00);
@@ -1359,7 +1365,8 @@ sioprobe(dev, xrid)
default:
printf("sio%d: irq configuration error\n",
device_get_unit(dev));
- return (0);
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
}
outb((isa_get_port(dev) & 0x00ff) | tmp, irqout);
}
@@ -1761,8 +1768,10 @@ sioattach(dev, xrid)
iobase += 8;
obufsize = 2048;
}
- if ((obuf = malloc(obufsize * 2, M_DEVBUF, M_NOWAIT)) == NULL)
+ if ((obuf = malloc(obufsize * 2, M_DEVBUF, M_NOWAIT)) == NULL) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return ENXIO;
+ }
bzero(obuf, obufsize * 2);
#endif
diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c
index 492b7ee..2cce636729 100644
--- a/sys/pc98/pc98/sio.c
+++ b/sys/pc98/pc98/sio.c
@@ -1244,8 +1244,10 @@ sioprobe(dev, xrid)
/*
* If the port is i8251 UART (internal, B98_01)
*/
- if (pc98_check_if_type(dev, &iod) == -1)
+ if (pc98_check_if_type(dev, &iod) == -1) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return (ENXIO);
+ }
if (iod.irq > 0)
bus_set_resource(dev, SYS_RES_IRQ, 0, iod.irq, 1);
if (IS_8251(iod.if_type)) {
@@ -1334,14 +1336,18 @@ sioprobe(dev, xrid)
mcr_image = 0;
rsabase = iobase & 0xfff0;
- if (rsabase != iobase)
- return(0);
+ if (rsabase != iobase) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
+ }
iobase += 8;
outb(rsabase + rsa_msr, 0x04);
outb(rsabase + rsa_frr, 0x00);
- if ((inb(rsabase + rsa_srr) & 0x36) != 0x36)
- return (0);
+ if ((inb(rsabase + rsa_srr) & 0x36) != 0x36) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
+ }
outb(rsabase + rsa_ier, 0x00);
outb(rsabase + rsa_frr, 0x00);
outb(rsabase + rsa_tivsr, 0x00);
@@ -1359,7 +1365,8 @@ sioprobe(dev, xrid)
default:
printf("sio%d: irq configuration error\n",
device_get_unit(dev));
- return (0);
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
+ return (ENXIO);
}
outb((isa_get_port(dev) & 0x00ff) | tmp, irqout);
}
@@ -1761,8 +1768,10 @@ sioattach(dev, xrid)
iobase += 8;
obufsize = 2048;
}
- if ((obuf = malloc(obufsize * 2, M_DEVBUF, M_NOWAIT)) == NULL)
+ if ((obuf = malloc(obufsize * 2, M_DEVBUF, M_NOWAIT)) == NULL) {
+ bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
return ENXIO;
+ }
bzero(obuf, obufsize * 2);
#endif
OpenPOWER on IntegriCloud