diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-01-09 18:50:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2012-01-09 18:50:45 +0000 |
commit | 661fcbc4ee50b681186ed124d4a4e2b97a151961 (patch) | |
tree | a30d2c53f802685f2e146e06e6db28dfd344cff1 /sys/dev/ic | |
parent | 1f4e3c7ba0f4df1dcba845786357b287ae848442 (diff) |
repair errors paths for dma_alloc; spotted by dhill
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/ami.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index 8d4b8a97690..a42bae451e2 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.222 2012/01/09 15:43:15 deraadt Exp $ */ +/* $OpenBSD: ami.c,v 1.223 2012/01/09 18:50:44 deraadt Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -1702,8 +1702,8 @@ ami_drv_inq(struct ami_softc *sc, u_int8_t ch, u_int8_t tg, u_int8_t page, int ami_drv_readcap(struct ami_softc *sc, u_int8_t ch, u_int8_t tg, daddr64_t *sz) { - struct scsi_read_cap_data *rcd; - struct scsi_read_cap_data_16 *rcd16; + struct scsi_read_cap_data *rcd = NULL; + struct scsi_read_cap_data_16 *rcd16 = NULL; u_int8_t cdb[16]; u_int32_t blksz; daddr64_t noblk; @@ -1715,7 +1715,7 @@ ami_drv_readcap(struct ami_softc *sc, u_int8_t ch, u_int8_t tg, daddr64_t *sz) error = ami_drv_pt(sc, ch, tg, cdb, 10, sizeof(*rcd), rcd); if (error) - return (error); + goto fail; noblk = _4btol(rcd->addr); if (noblk == 0xffffffffllu) { @@ -1726,21 +1726,21 @@ ami_drv_readcap(struct ami_softc *sc, u_int8_t ch, u_int8_t tg, daddr64_t *sz) error = ami_drv_pt(sc, ch, tg, cdb, 16, sizeof(*rcd16), rcd16); if (error) - return (error); + goto fail; noblk = _8btol(rcd16->addr); blksz = _4btol(rcd16->length); - - dma_free(rcd16, sizeof(*rcd16)); } else blksz = _4btol(rcd->length); - dma_free(rcd, sizeof(*rcd)); - if (blksz == 0) blksz = 512; *sz = noblk * blksz; +fail: + if (rcd16) + dma_free(rcd16, sizeof(*rcd16)); + dma_free(rcd, sizeof(*rcd)); return (error); } |