Release allocated resources and return ENXIO on error.
This commit is contained in:
parent
7a15d61951
commit
4b38c2c0ac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59493
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user