diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-20 17:32:48 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-05-20 17:32:48 +0200 |
commit | c4f57ff4927986ac2c45e1d4a84ad425a9c9aae9 (patch) | |
tree | fc75883a1df76b2ab672d74d3007586e05c9c347 /sys/src/9/pc/uartisa.c | |
parent | 6ac8a3ca650ead149ed4062a6b06c92a7a961520 (diff) |
pcuart: malloc error handling, cleanup
Diffstat (limited to 'sys/src/9/pc/uartisa.c')
-rw-r--r-- | sys/src/9/pc/uartisa.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/src/9/pc/uartisa.c b/sys/src/9/pc/uartisa.c index f02080d70..f6b590724 100644 --- a/sys/src/9/pc/uartisa.c +++ b/sys/src/9/pc/uartisa.c @@ -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; |