]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/pc/uartisa.c
pc/ether*: use 64-bit physical addresses and check pci membar types and sizes
[plan9front.git] / sys / src / 9 / pc / uartisa.c
index f02080d70247e4a4feb588a10a1587559771f775..f6b590724263b90b341677cc127bf5d004630552 100644 (file)
@@ -18,16 +18,22 @@ uartisa(int ctlrno, ISAConf* isa)
        Uart *uart;
        char buf[64];
 
+       uart = malloc(sizeof(Uart));
+       if(uart == nil){
+               print("uartisa: no memory for Uart\n");
+               return nil;
+       }
+
        io = isa->port;
        snprint(buf, sizeof(buf), "%s%d", isaphysuart.name, ctlrno);
        if(ioalloc(io, 8, 0, buf) < 0){
                print("uartisa: I/O 0x%uX in use\n", io);
+               free(uart);
                return nil;
        }
 
-       uart = malloc(sizeof(Uart));
        ctlr = i8250alloc(io, isa->irq, BUSUNKNOWN);
-       if(uart == nil || ctlr == nil){
+       if(ctlr == nil){
                iofree(io);
                free(uart);
                return nil;