summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_nxe.c8
-rw-r--r--sys/dev/pci/if_wpi.c21
-rw-r--r--sys/dev/pci/if_wpivar.h3
-rw-r--r--sys/dev/pci/mfii.c8
-rw-r--r--sys/dev/pci/mpii.c47
5 files changed, 44 insertions, 43 deletions
diff --git a/sys/dev/pci/if_nxe.c b/sys/dev/pci/if_nxe.c
index 9b30900daed..890a8db8f8e 100644
--- a/sys/dev/pci/if_nxe.c
+++ b/sys/dev/pci/if_nxe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_nxe.c,v 1.74 2017/01/22 10:17:38 dlg Exp $ */
+/* $OpenBSD: if_nxe.c,v 1.75 2017/04/08 02:57:25 deraadt Exp $ */
/*
* Copyright (c) 2007 David Gwynne <dlg@openbsd.org>
@@ -1949,7 +1949,7 @@ nxe_pkt_free(struct nxe_softc *sc, struct nxe_pkt_list *npl)
bus_dmamap_destroy(sc->sc_dmat, pkt->pkt_dmap);
free(npl->npl_pkts, M_DEVBUF, 0);
- free(npl, M_DEVBUF, 0);
+ free(npl, M_DEVBUF, sizeof *npl);
}
struct nxe_pkt *
@@ -2014,7 +2014,7 @@ free:
destroy:
bus_dmamap_destroy(sc->sc_dmat, ndm->ndm_map);
ndmfree:
- free(ndm, M_DEVBUF, 0);
+ free(ndm, M_DEVBUF, sizeof *ndm);
return (NULL);
}
@@ -2025,7 +2025,7 @@ nxe_dmamem_free(struct nxe_softc *sc, struct nxe_dmamem *ndm)
bus_dmamem_unmap(sc->sc_dmat, ndm->ndm_kva, ndm->ndm_size);
bus_dmamem_free(sc->sc_dmat, &ndm->ndm_seg, 1);
bus_dmamap_destroy(sc->sc_dmat, ndm->ndm_map);
- free(ndm, M_DEVBUF, 0);
+ free(ndm, M_DEVBUF, sizeof *ndm);
}
u_int32_t
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index edc03dd0d76..5106d75a6b2 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.139 2017/03/08 12:02:41 mpi Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.140 2017/04/08 02:57:25 deraadt Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -2957,19 +2957,18 @@ wpi_read_firmware(struct wpi_softc *sc)
{
struct wpi_fw_info *fw = &sc->fw;
const struct wpi_firmware_hdr *hdr;
- size_t size;
int error;
/* Read firmware image from filesystem. */
- if ((error = loadfirmware("wpi-3945abg", &fw->data, &size)) != 0) {
+ if ((error = loadfirmware("wpi-3945abg", &fw->data, &fw->datalen)) != 0) {
printf("%s: error, %d, could not read firmware %s\n",
sc->sc_dev.dv_xname, error, "wpi-3945abg");
return error;
}
- if (size < sizeof (*hdr)) {
+ if (fw->datalen < sizeof (*hdr)) {
printf("%s: truncated firmware header: %zu bytes\n",
- sc->sc_dev.dv_xname, size);
- free(fw->data, M_DEVBUF, size);
+ sc->sc_dev.dv_xname, fw->datalen);
+ free(fw->data, M_DEVBUF, fw->datalen);
return EINVAL;
}
/* Extract firmware header information. */
@@ -2989,16 +2988,16 @@ wpi_read_firmware(struct wpi_softc *sc)
fw->boot.textsz > WPI_FW_BOOT_TEXT_MAXSZ ||
(fw->boot.textsz & 3) != 0) {
printf("%s: invalid firmware header\n", sc->sc_dev.dv_xname);
- free(fw->data, M_DEVBUF, size);
+ free(fw->data, M_DEVBUF, fw->datalen);
return EINVAL;
}
/* Check that all firmware sections fit. */
- if (size < sizeof (*hdr) + fw->main.textsz + fw->main.datasz +
+ if (fw->datalen < sizeof (*hdr) + fw->main.textsz + fw->main.datasz +
fw->init.textsz + fw->init.datasz + fw->boot.textsz) {
printf("%s: firmware file too short: %zu bytes\n",
- sc->sc_dev.dv_xname, size);
- free(fw->data, M_DEVBUF, size);
+ sc->sc_dev.dv_xname, fw->datalen);
+ free(fw->data, M_DEVBUF, fw->datalen);
return EINVAL;
}
@@ -3290,7 +3289,7 @@ wpi_init(struct ifnet *ifp)
/* Initialize hardware and upload firmware. */
error = wpi_hw_init(sc);
- free(sc->fw.data, M_DEVBUF, 0);
+ free(sc->fw.data, M_DEVBUF, sc->fw.datalen);
if (error != 0) {
printf("%s: could not initialize hardware\n",
sc->sc_dev.dv_xname);
diff --git a/sys/dev/pci/if_wpivar.h b/sys/dev/pci/if_wpivar.h
index 755f2c16ac9..849208b2319 100644
--- a/sys/dev/pci/if_wpivar.h
+++ b/sys/dev/pci/if_wpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpivar.h,v 1.26 2016/09/05 08:18:40 tedu Exp $ */
+/* $OpenBSD: if_wpivar.h,v 1.27 2017/04/08 02:57:25 deraadt Exp $ */
/*-
* Copyright (c) 2006-2008
@@ -123,6 +123,7 @@ struct wpi_fw_part {
struct wpi_fw_info {
u_char *data;
+ size_t datalen;
struct wpi_fw_part init;
struct wpi_fw_part main;
struct wpi_fw_part boot;
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c
index 38dffe7f9df..95e9e69bf39 100644
--- a/sys/dev/pci/mfii.c
+++ b/sys/dev/pci/mfii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfii.c,v 1.42 2017/02/11 04:12:28 dlg Exp $ */
+/* $OpenBSD: mfii.c,v 1.43 2017/04/08 02:57:25 deraadt Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@openbsd.org>
@@ -719,7 +719,7 @@ mfii_syspd(struct mfii_softc *sc)
return (0);
free_pdsc:
- free(sc->sc_pd, M_DEVBUF, 0);
+ free(sc->sc_pd, M_DEVBUF, sizeof(*sc->sc_pd));
return (1);
}
@@ -795,7 +795,7 @@ free:
destroy:
bus_dmamap_destroy(sc->sc_dmat, m->mdm_map);
mdmfree:
- free(m, M_DEVBUF, 0);
+ free(m, M_DEVBUF, sizeof *m);
return (NULL);
}
@@ -807,7 +807,7 @@ mfii_dmamem_free(struct mfii_softc *sc, struct mfii_dmamem *m)
bus_dmamem_unmap(sc->sc_dmat, m->mdm_kva, m->mdm_size);
bus_dmamem_free(sc->sc_dmat, &m->mdm_seg, 1);
bus_dmamap_destroy(sc->sc_dmat, m->mdm_map);
- free(m, M_DEVBUF, 0);
+ free(m, M_DEVBUF, sizeof *m);
}
void
diff --git a/sys/dev/pci/mpii.c b/sys/dev/pci/mpii.c
index b3fa2087260..2738823da81 100644
--- a/sys/dev/pci/mpii.c
+++ b/sys/dev/pci/mpii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpii.c,v 1.110 2017/01/16 18:18:16 mikeb Exp $ */
+/* $OpenBSD: mpii.c,v 1.111 2017/04/08 02:57:25 deraadt Exp $ */
/*
* Copyright (c) 2010, 2012 Mike Belopuhov
* Copyright (c) 2009 James Giannoules
@@ -1764,7 +1764,7 @@ mpii_event_raid(struct mpii_softc *sc, struct mpii_msg_event_reply *enp)
dev->slot = sc->sc_vd_id_low;
dev->dev_handle = lemtoh16(&ce->vol_dev_handle);
if (mpii_insert_dev(sc, dev)) {
- free(dev, M_DEVBUF, 0);
+ free(dev, M_DEVBUF, sizeof *dev);
break;
}
sc->sc_vd_count++;
@@ -1871,7 +1871,7 @@ mpii_event_sas(void *xsc)
dev->expander = lemtoh16(&tcl->expander_handle);
if (mpii_insert_dev(sc, dev)) {
- free(dev, M_DEVBUF, 0);
+ free(dev, M_DEVBUF, sizeof *dev);
break;
}
@@ -1894,7 +1894,7 @@ mpii_event_sas(void *xsc)
DETACH_FORCE);
}
- free(dev, M_DEVBUF, 0);
+ free(dev, M_DEVBUF, sizeof *dev);
break;
}
}
@@ -2419,7 +2419,7 @@ free:
destroy:
bus_dmamap_destroy(sc->sc_dmat, mdm->mdm_map);
mdmfree:
- free(mdm, M_DEVBUF, 0);
+ free(mdm, M_DEVBUF, sizeof *mdm);
return (NULL);
}
@@ -2433,7 +2433,7 @@ mpii_dmamem_free(struct mpii_softc *sc, struct mpii_dmamem *mdm)
bus_dmamem_unmap(sc->sc_dmat, mdm->mdm_kva, mdm->mdm_size);
bus_dmamem_free(sc->sc_dmat, &mdm->mdm_seg, 1);
bus_dmamap_destroy(sc->sc_dmat, mdm->mdm_map);
- free(mdm, M_DEVBUF, 0);
+ free(mdm, M_DEVBUF, sizeof *mdm);
}
int
@@ -2565,7 +2565,7 @@ free_maps:
mpii_dmamem_free(sc, sc->sc_requests);
free_ccbs:
- free(sc->sc_ccbs, M_DEVBUF, 0);
+ free(sc->sc_ccbs, M_DEVBUF, (sc->sc_max_cmds-1) * sizeof(*ccb));
return (1);
}
@@ -2627,7 +2627,8 @@ mpii_alloc_replies(struct mpii_softc *sc)
sc->sc_replies = mpii_dmamem_alloc(sc, sc->sc_reply_size *
sc->sc_num_reply_frames);
if (sc->sc_replies == NULL) {
- free(sc->sc_rcbs, M_DEVBUF, 0);
+ free(sc->sc_rcbs, M_DEVBUF,
+ sc->sc_num_reply_frames * sizeof(struct mpii_rcb));
return (1);
}
@@ -3241,7 +3242,7 @@ mpii_ioctl_cache(struct scsi_link *link, u_long cmd, struct dk_cache *dc)
scsi_io_put(&sc->sc_iopool, ccb);
done:
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (rv);
}
@@ -3328,7 +3329,7 @@ mpii_ioctl_vol(struct mpii_softc *sc, struct bioc_vol *bv)
&hdr, 1, vpg, pagelen) != 0) {
printf("%s: unable to fetch raid volume page 0\n",
DEVNAME(sc));
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (EINVAL);
}
@@ -3373,7 +3374,7 @@ mpii_ioctl_vol(struct mpii_softc *sc, struct bioc_vol *bv)
}
if ((rv = mpii_bio_hs(sc, NULL, 0, vpg->hot_spare_pool, &hcnt)) != 0) {
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (rv);
}
@@ -3387,7 +3388,7 @@ mpii_ioctl_vol(struct mpii_softc *sc, struct bioc_vol *bv)
strlcpy(bv->bv_dev, scdev->dv_xname, sizeof(bv->bv_dev));
}
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (0);
}
@@ -3428,7 +3429,7 @@ mpii_ioctl_disk(struct mpii_softc *sc, struct bioc_disk *bd)
&hdr, 1, vpg, pagelen) != 0) {
printf("%s: unable to fetch raid volume page 0\n",
DEVNAME(sc));
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (EINVAL);
}
@@ -3436,7 +3437,7 @@ mpii_ioctl_disk(struct mpii_softc *sc, struct bioc_disk *bd)
int nvdsk = vpg->num_phys_disks;
int hsmap = vpg->hot_spare_pool;
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (mpii_bio_hs(sc, bd, nvdsk, hsmap, NULL));
}
@@ -3444,7 +3445,7 @@ mpii_ioctl_disk(struct mpii_softc *sc, struct bioc_disk *bd)
bd->bd_diskid;
dn = pd->phys_disk_num;
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (mpii_bio_disk(sc, bd, dn));
}
@@ -3484,7 +3485,7 @@ mpii_bio_hs(struct mpii_softc *sc, struct bioc_disk *bd, int nvdsk,
MPII_PG_EXTENDED, &ehdr, 1, cpg, pagelen) != 0) {
printf("%s: unable to fetch raid config page 0\n",
DEVNAME(sc));
- free(cpg, M_TEMP, 0);
+ free(cpg, M_TEMP, pagelen);
return (EINVAL);
}
@@ -3503,7 +3504,7 @@ mpii_bio_hs(struct mpii_softc *sc, struct bioc_disk *bd, int nvdsk,
if (bd != NULL && bd->bd_diskid == nhs + nvdsk) {
u_int8_t dn = el->phys_disk_num;
- free(cpg, M_TEMP, 0);
+ free(cpg, M_TEMP, pagelen);
return (mpii_bio_disk(sc, bd, dn));
}
nhs++;
@@ -3513,7 +3514,7 @@ mpii_bio_hs(struct mpii_softc *sc, struct bioc_disk *bd, int nvdsk,
if (hscnt)
*hscnt = nhs;
- free(cpg, M_TEMP, 0);
+ free(cpg, M_TEMP, pagelen);
return (0);
}
@@ -3544,7 +3545,7 @@ mpii_bio_disk(struct mpii_softc *sc, struct bioc_disk *bd, u_int8_t dn)
&hdr, 1, ppg, sizeof(*ppg)) != 0) {
printf("%s: unable to fetch raid drive page 0\n",
DEVNAME(sc));
- free(ppg, M_TEMP, 0);
+ free(ppg, M_TEMP, sizeof(*ppg));
return (EINVAL);
}
@@ -3552,7 +3553,7 @@ mpii_bio_disk(struct mpii_softc *sc, struct bioc_disk *bd, u_int8_t dn)
if ((dev = mpii_find_dev(sc, lemtoh16(&ppg->dev_handle))) == NULL) {
bd->bd_status = BIOC_SDINVALID;
- free(ppg, M_TEMP, 0);
+ free(ppg, M_TEMP, sizeof(*ppg));
return (0);
}
@@ -3597,7 +3598,7 @@ mpii_bio_disk(struct mpii_softc *sc, struct bioc_disk *bd, u_int8_t dn)
sizeof(ppg->product_id));
scsi_strvis(bd->bd_serial, ppg->serial, sizeof(ppg->serial));
- free(ppg, M_TEMP, 0);
+ free(ppg, M_TEMP, sizeof(*ppg));
return (0);
}
@@ -3650,7 +3651,7 @@ mpii_bio_volstate(struct mpii_softc *sc, struct bioc_vol *bv)
MPII_PG_POLL, &hdr, 1, vpg, pagelen) != 0) {
DNPRINTF(MPII_D_MISC, "%s: unable to fetch raid volume "
"page 0\n", DEVNAME(sc));
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (EINVAL);
}
@@ -3678,7 +3679,7 @@ mpii_bio_volstate(struct mpii_softc *sc, struct bioc_vol *bv)
break;
}
- free(vpg, M_TEMP, 0);
+ free(vpg, M_TEMP, pagelen);
return (0);
}