diff --git a/sys/dev/cardbus/cardbus_cis.c b/sys/dev/cardbus/cardbus_cis.c index e7bf55e013a4..83442c2d0d4a 100644 --- a/sys/dev/cardbus/cardbus_cis.c +++ b/sys/dev/cardbus/cardbus_cis.c @@ -583,7 +583,7 @@ int cardbus_parse_cis(device_t cbdev, device_t child, struct tuple_callbacks *callbacks, void *argp) { - uint8_t tupledata[MAXTUPLESIZE]; + uint8_t *tupledata; int tupleid = CISTPL_NULL; int len; int expect_linktarget; @@ -591,10 +591,11 @@ cardbus_parse_cis(device_t cbdev, device_t child, struct resource *res; int rid; - bzero(tupledata, MAXTUPLESIZE); + tupledata = malloc(MAXTUPLESIZE, M_DEVBUF, M_WAITOK | M_ZERO); expect_linktarget = TRUE; if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) { DEVPRINTF((cbdev, "Warning: CIS pointer is 0: (no CIS)\n")); + free(tupledata, M_DEVBUF); return (0); } DEVPRINTF((cbdev, "CIS pointer is %#x\n", start)); @@ -602,6 +603,7 @@ cardbus_parse_cis(device_t cbdev, device_t child, res = cardbus_read_tuple_init(cbdev, child, &start, &rid); if (res == NULL) { device_printf(cbdev, "Unable to allocate resources for CIS\n"); + free(tupledata, M_DEVBUF); return (ENXIO); } @@ -610,6 +612,7 @@ cardbus_parse_cis(device_t cbdev, device_t child, &tupleid, &len, tupledata) != 0) { device_printf(cbdev, "Failed to read CIS.\n"); cardbus_read_tuple_finish(cbdev, child, rid, res); + free(tupledata, M_DEVBUF); return (ENXIO); } @@ -617,6 +620,7 @@ cardbus_parse_cis(device_t cbdev, device_t child, device_printf(cbdev, "Expecting link target, got 0x%x\n", tupleid); cardbus_read_tuple_finish(cbdev, child, rid, res); + free(tupledata, M_DEVBUF); return (EINVAL); } expect_linktarget = decode_tuple(cbdev, child, tupleid, len, @@ -625,10 +629,12 @@ cardbus_parse_cis(device_t cbdev, device_t child, device_printf(cbdev, "Parsing failed with %d\n", expect_linktarget); cardbus_read_tuple_finish(cbdev, child, rid, res); + free(tupledata, M_DEVBUF); return (expect_linktarget); } } while (tupleid != CISTPL_END); cardbus_read_tuple_finish(cbdev, child, rid, res); + free(tupledata, M_DEVBUF); return (0); }