summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/usb/if_athn_usb.c11
-rw-r--r--sys/dev/usb/if_atu.c22
-rw-r--r--sys/dev/usb/if_kue.c10
-rw-r--r--sys/dev/usb/if_otus.c9
-rw-r--r--sys/dev/usb/if_rsu.c4
-rw-r--r--sys/dev/usb/if_rum.c4
-rw-r--r--sys/dev/usb/if_run.c6
-rw-r--r--sys/dev/usb/if_uath.c4
-rw-r--r--sys/dev/usb/if_upgt.c4
-rw-r--r--sys/dev/usb/if_urndis.c20
-rw-r--r--sys/dev/usb/if_zyd.c4
-rw-r--r--sys/dev/usb/udl.c9
-rw-r--r--sys/dev/usb/udl.h3
-rw-r--r--sys/dev/usb/ulpt.c4
-rw-r--r--sys/dev/usb/usb_subr.c6
-rw-r--r--sys/dev/usb/uticom.c8
-rw-r--r--sys/dev/usb/uvideo.c14
17 files changed, 74 insertions, 68 deletions
diff --git a/sys/dev/usb/if_athn_usb.c b/sys/dev/usb/if_athn_usb.c
index c31f3d1fed7..6c0b88c715f 100644
--- a/sys/dev/usb/if_athn_usb.c
+++ b/sys/dev/usb/if_athn_usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_athn_usb.c,v 1.45 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_athn_usb.c,v 1.46 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2011 Damien Bergamini <damien.bergamini@free.fr>
@@ -621,7 +621,7 @@ athn_usb_load_firmware(struct athn_usb_softc *usc)
usb_device_request_t req;
const char *name;
u_char *fw, *ptr;
- size_t size;
+ size_t fwsize, size;
uint32_t addr;
int s, mlen, error;
@@ -635,7 +635,7 @@ athn_usb_load_firmware(struct athn_usb_softc *usc)
} else
name = "athn-ar9271";
/* Read firmware image from the filesystem. */
- if ((error = loadfirmware(name, &fw, &size)) != 0) {
+ if ((error = loadfirmware(name, &fw, &fwsize)) != 0) {
printf("%s: failed loadfirmware of file %s (error %d)\n",
usc->usb_dev.dv_xname, name, error);
return (error);
@@ -646,6 +646,7 @@ athn_usb_load_firmware(struct athn_usb_softc *usc)
req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
req.bRequest = AR_FW_DOWNLOAD;
USETW(req.wIndex, 0);
+ size = fwsize;
while (size > 0) {
mlen = MIN(size, 4096);
@@ -653,14 +654,14 @@ athn_usb_load_firmware(struct athn_usb_softc *usc)
USETW(req.wLength, mlen);
error = usbd_do_request(usc->sc_udev, &req, ptr);
if (error != 0) {
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, fwsize);
return (error);
}
addr += mlen >> 8;
ptr += mlen;
size -= mlen;
}
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, fwsize);
/* Start firmware. */
if (usc->flags & ATHN_USB_FLAG_AR7010)
diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c
index 725a6dbb66b..44f3723b5d9 100644
--- a/sys/dev/usb/if_atu.c
+++ b/sys/dev/usb/if_atu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_atu.c,v 1.121 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_atu.c,v 1.122 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004
* Daan Vreeken <Danovitsch@Vitsch.net>. All rights reserved.
@@ -857,7 +857,7 @@ atu_internal_firmware(struct device *self)
struct atu_softc *sc = (struct atu_softc *)self;
u_char state, *ptr = NULL, *firm = NULL, status[6];
int block_size, block = 0, err, i;
- size_t bytes_left = 0;
+ size_t firm_len, bytes_left = 0;
char *name = "unknown-device";
/*
@@ -886,7 +886,7 @@ atu_internal_firmware(struct device *self)
DPRINTF(("%s: loading firmware %s...\n",
sc->atu_dev.dv_xname, name));
- err = loadfirmware(name, &firm, &bytes_left);
+ err = loadfirmware(name, &firm, &firm_len);
if (err != 0) {
printf("%s: %s loadfirmware error %d\n",
sc->atu_dev.dv_xname, name, err);
@@ -894,6 +894,7 @@ atu_internal_firmware(struct device *self)
}
ptr = firm;
+ bytes_left = firm_len;
state = atu_get_dfu_state(sc);
while (block >= 0 && state > 0) {
@@ -905,7 +906,7 @@ atu_internal_firmware(struct device *self)
if (err) {
DPRINTF(("%s: dfu_getstatus failed!\n",
sc->atu_dev.dv_xname));
- free(firm, M_DEVBUF, 0);
+ free(firm, M_DEVBUF, firm_len);
goto fail;
}
/* success means state => DnLoadIdle */
@@ -927,7 +928,7 @@ atu_internal_firmware(struct device *self)
if (err) {
DPRINTF(("%s: dfu_dnload failed\n",
sc->atu_dev.dv_xname));
- free(firm, M_DEVBUF, 0);
+ free(firm, M_DEVBUF, firm_len);
goto fail;
}
@@ -946,7 +947,7 @@ atu_internal_firmware(struct device *self)
state = atu_get_dfu_state(sc);
}
- free(firm, M_DEVBUF, 0);
+ free(firm, M_DEVBUF, firm_len);
if (state != DFUState_ManifestSync) {
DPRINTF(("%s: state != manifestsync... eek!\n",
@@ -988,7 +989,7 @@ atu_external_firmware(struct device *self)
struct atu_softc *sc = (struct atu_softc *)self;
u_char *ptr = NULL, *firm = NULL;
int block_size, block = 0, err, i;
- size_t bytes_left = 0;
+ size_t firm_len, bytes_left = 0;
char *name = "unknown-device";
for (i = 0; i < nitems(atu_radfirm); i++)
@@ -997,13 +998,14 @@ atu_external_firmware(struct device *self)
DPRINTF(("%s: loading external firmware %s\n",
sc->atu_dev.dv_xname, name));
- err = loadfirmware(name, &firm, &bytes_left);
+ err = loadfirmware(name, &firm, &firm_len);
if (err != 0) {
printf("%s: %s loadfirmware error %d\n",
sc->atu_dev.dv_xname, name, err);
return;
}
ptr = firm;
+ bytes_left = firm_len;
while (bytes_left) {
if (bytes_left > 1024)
@@ -1018,7 +1020,7 @@ atu_external_firmware(struct device *self)
if (err) {
DPRINTF(("%s: could not load external firmware "
"block\n", sc->atu_dev.dv_xname));
- free(firm, M_DEVBUF, 0);
+ free(firm, M_DEVBUF, firm_len);
return;
}
@@ -1026,7 +1028,7 @@ atu_external_firmware(struct device *self)
block++;
bytes_left -= block_size;
}
- free(firm, M_DEVBUF, 0);
+ free(firm, M_DEVBUF, firm_len);
err = atu_usb_request(sc, UT_WRITE_VENDOR_DEVICE, 0x0e, 0x0802,
block, 0, NULL);
diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c
index 4b8fad7c36c..8df9089790e 100644
--- a/sys/dev/usb/if_kue.c
+++ b/sys/dev/usb/if_kue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_kue.c,v 1.86 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_kue.c,v 1.87 2017/03/26 15:31:15 deraadt Exp $ */
/* $NetBSD: if_kue.c,v 1.50 2002/07/16 22:00:31 augustss Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -270,7 +270,7 @@ kue_load_fw(struct kue_softc *sc)
if (err) {
printf("%s: failed to load code segment: %s\n",
sc->kue_dev.dv_xname, usbd_errstr(err));
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, buflen);
return (EIO);
}
@@ -282,7 +282,7 @@ kue_load_fw(struct kue_softc *sc)
if (err) {
printf("%s: failed to load fixup segment: %s\n",
sc->kue_dev.dv_xname, usbd_errstr(err));
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, buflen);
return (EIO);
}
@@ -295,10 +295,10 @@ kue_load_fw(struct kue_softc *sc)
if (err) {
printf("%s: failed to load trigger segment: %s\n",
sc->kue_dev.dv_xname, usbd_errstr(err));
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, buflen);
return (EIO);
}
- free(buf, M_DEVBUF, 0);
+ free(buf, M_DEVBUF, buflen);
usbd_delay_ms(sc->kue_udev, 10);
diff --git a/sys/dev/usb/if_otus.c b/sys/dev/usb/if_otus.c
index 1025fa8c8b2..7e2507771f2 100644
--- a/sys/dev/usb/if_otus.c
+++ b/sys/dev/usb/if_otus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_otus.c,v 1.55 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_otus.c,v 1.56 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr>
@@ -416,12 +416,12 @@ int
otus_load_firmware(struct otus_softc *sc, const char *name, uint32_t addr)
{
usb_device_request_t req;
- size_t size;
+ size_t fwsize, size;
u_char *fw, *ptr;
int mlen, error;
/* Read firmware image from the filesystem. */
- if ((error = loadfirmware(name, &fw, &size)) != 0) {
+ if ((error = loadfirmware(name, &fw, &fwsize)) != 0) {
printf("%s: failed loadfirmware of file %s (error %d)\n",
sc->sc_dev.dv_xname, name, error);
return error;
@@ -431,6 +431,7 @@ otus_load_firmware(struct otus_softc *sc, const char *name, uint32_t addr)
USETW(req.wIndex, 0);
ptr = fw;
+ size = fwsize;
addr >>= 8;
while (size > 0) {
mlen = MIN(size, 4096);
@@ -445,7 +446,7 @@ otus_load_firmware(struct otus_softc *sc, const char *name, uint32_t addr)
ptr += mlen;
size -= mlen;
}
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, fwsize);
return error;
}
diff --git a/sys/dev/usb/if_rsu.c b/sys/dev/usb/if_rsu.c
index b922d0c7580..a88fab44bad 100644
--- a/sys/dev/usb/if_rsu.c
+++ b/sys/dev/usb/if_rsu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rsu.c,v 1.37 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_rsu.c,v 1.38 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -2139,7 +2139,7 @@ rsu_load_firmware(struct rsu_softc *sc)
goto fail;
}
fail:
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, size);
return (error);
}
diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c
index 37bd8926324..49ab637ddcc 100644
--- a/sys/dev/usb/if_rum.c
+++ b/sys/dev/usb/if_rum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rum.c,v 1.120 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_rum.c,v 1.121 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
@@ -254,7 +254,7 @@ rum_attachhook(struct device *self)
sc->sc_dev.dv_xname);
}
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, size);
}
void
diff --git a/sys/dev/usb/if_run.c b/sys/dev/usb/if_run.c
index 4cbfa8a67ae..4401282b27f 100644
--- a/sys/dev/usb/if_run.c
+++ b/sys/dev/usb/if_run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_run.c,v 1.117 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_run.c,v 1.118 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -842,14 +842,14 @@ run_load_microcode(struct run_softc *sc)
if (size != 4096) {
printf("%s: invalid firmware size (should be 4KB)\n",
sc->sc_dev.dv_xname);
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, size);
return EINVAL;
}
run_read(sc, RT2860_ASIC_VER_ID, &tmp);
/* write microcode image */
run_write_region_1(sc, RT2870_FW_BASE, ucode, size);
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, size);
run_write(sc, RT2860_H2M_MAILBOX_CID, 0xffffffff);
run_write(sc, RT2860_H2M_MAILBOX_STATUS, 0xffffffff);
diff --git a/sys/dev/usb/if_uath.c b/sys/dev/usb/if_uath.c
index 1c3ba77970a..96ec1ef753e 100644
--- a/sys/dev/usb/if_uath.c
+++ b/sys/dev/usb/if_uath.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_uath.c,v 1.79 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_uath.c,v 1.80 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2006
@@ -213,7 +213,7 @@ uath_attachhook(struct device *self)
}
error = uath_loadfirmware(sc, fw, size);
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, size);
if (error == 0) {
/*
diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c
index 19ba4ffc66a..5d3ce0b8118 100644
--- a/sys/dev/usb/if_upgt.c
+++ b/sys/dev/usb/if_upgt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_upgt.c,v 1.79 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_upgt.c,v 1.80 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -612,7 +612,7 @@ void
upgt_fw_free(struct upgt_softc *sc)
{
if (sc->sc_fw != NULL) {
- free(sc->sc_fw, M_DEVBUF, 0);
+ free(sc->sc_fw, M_DEVBUF, sc->sc_fw_size);
sc->sc_fw = NULL;
DPRINTF(1, "%s: firmware freed\n", sc->sc_dev.dv_xname);
}
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c
index 7b584e88b00..c31d5c7d5be 100644
--- a/sys/dev/usb/if_urndis.c
+++ b/sys/dev/usb/if_urndis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_urndis.c,v 1.63 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_urndis.c,v 1.64 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
@@ -182,7 +182,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
if (err != USBD_NORMAL_COMPLETION && err != USBD_SHORT_XFER) {
printf("%s: %s\n", DEVNAME(sc), usbd_errstr(err));
- free(buf, M_TEMP, 0);
+ free(buf, M_TEMP, RNDIS_RESPONSE_LEN);
return NULL;
}
@@ -197,7 +197,7 @@ urndis_ctrl_recv(struct urndis_softc *sc)
DEVNAME(sc),
letoh32(hdr->rm_len),
RNDIS_RESPONSE_LEN);
- free(buf, M_TEMP, 0);
+ free(buf, M_TEMP, RNDIS_RESPONSE_LEN);
return NULL;
}
@@ -432,7 +432,7 @@ urndis_ctrl_init(struct urndis_softc *sc)
letoh32(msg->rm_max_xfersz)));
rval = urndis_ctrl_send(sc, msg, sizeof(*msg));
- free(msg, M_TEMP, 0);
+ free(msg, M_TEMP, sizeof *msg);
if (rval != RNDIS_STATUS_SUCCESS) {
printf("%s: init failed\n", DEVNAME(sc));
@@ -471,7 +471,7 @@ urndis_ctrl_halt(struct urndis_softc *sc)
letoh32(msg->rm_rid)));
rval = urndis_ctrl_send(sc, msg, sizeof(*msg));
- free(msg, M_TEMP, 0);
+ free(msg, M_TEMP, sizeof *msg);
if (rval != RNDIS_STATUS_SUCCESS)
printf("%s: halt failed\n", DEVNAME(sc));
@@ -518,7 +518,7 @@ urndis_ctrl_query(struct urndis_softc *sc, u_int32_t oid,
letoh32(msg->rm_devicevchdl)));
rval = urndis_ctrl_send(sc, msg, sizeof(*msg));
- free(msg, M_TEMP, 0);
+ free(msg, M_TEMP, sizeof *msg + qlen);
if (rval != RNDIS_STATUS_SUCCESS) {
printf("%s: query failed\n", DEVNAME(sc));
@@ -571,7 +571,7 @@ urndis_ctrl_set(struct urndis_softc *sc, u_int32_t oid, void *buf, size_t len)
letoh32(msg->rm_devicevchdl)));
rval = urndis_ctrl_send(sc, msg, sizeof(*msg) + len);
- free(msg, M_TEMP, 0);
+ free(msg, M_TEMP, sizeof *msg + len);
if (rval != RNDIS_STATUS_SUCCESS) {
printf("%s: set failed\n", DEVNAME(sc));
@@ -635,7 +635,7 @@ urndis_ctrl_set_param(struct urndis_softc *sc,
letoh32(param->rm_valuelen)));
rval = urndis_ctrl_set(sc, OID_GEN_RNDIS_CONFIG_PARAMETER, param, tlen);
- free(param, M_TEMP, 0);
+ free(param, M_TEMP, tlen);
if (rval != RNDIS_STATUS_SUCCESS)
printf("%s: set param failed 0x%x\n", DEVNAME(sc), rval);
@@ -668,7 +668,7 @@ urndis_ctrl_reset(struct urndis_softc *sc)
letoh32(reset->rm_rid)));
rval = urndis_ctrl_send(sc, reset, sizeof(*reset));
- free(reset, M_TEMP, 0);
+ free(reset, M_TEMP, sizeof *reset);
if (rval != RNDIS_STATUS_SUCCESS) {
printf("%s: reset failed\n", DEVNAME(sc));
@@ -708,7 +708,7 @@ urndis_ctrl_keepalive(struct urndis_softc *sc)
letoh32(keep->rm_rid)));
rval = urndis_ctrl_send(sc, keep, sizeof(*keep));
- free(keep, M_TEMP, 0);
+ free(keep, M_TEMP, sizeof *keep);
if (rval != RNDIS_STATUS_SUCCESS) {
printf("%s: keepalive failed\n", DEVNAME(sc));
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c
index 8acf80fb066..1e7ca99000c 100644
--- a/sys/dev/usb/if_zyd.c
+++ b/sys/dev/usb/if_zyd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_zyd.c,v 1.116 2017/01/22 10:17:39 dlg Exp $ */
+/* $OpenBSD: if_zyd.c,v 1.117 2017/03/26 15:31:15 deraadt Exp $ */
/*-
* Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
@@ -262,7 +262,7 @@ zyd_attachhook(struct device *self)
}
error = zyd_loadfirmware(sc, fw, size);
- free(fw, M_DEVBUF, 0);
+ free(fw, M_DEVBUF, size);
if (error != 0) {
printf("%s: could not load firmware (error=%d)\n",
sc->sc_dev.dv_xname, error);
diff --git a/sys/dev/usb/udl.c b/sys/dev/usb/udl.c
index b0709ca84e8..5083c3fc8d1 100644
--- a/sys/dev/usb/udl.c
+++ b/sys/dev/usb/udl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udl.c,v 1.85 2016/11/06 12:58:01 mpi Exp $ */
+/* $OpenBSD: udl.c,v 1.86 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@@ -1418,7 +1418,7 @@ void
udl_free_huffman(struct udl_softc *sc)
{
if (sc->sc_huffman != NULL) {
- free(sc->sc_huffman, M_DEVBUF, 0);
+ free(sc->sc_huffman, M_DEVBUF, sc->sc_huffman_size);
sc->sc_huffman = NULL;
sc->sc_huffman_size = 0;
DPRINTF(1, "%s: huffman table freed\n", DN(sc));
@@ -1438,7 +1438,7 @@ udl_fbmem_alloc(struct udl_softc *sc)
if (sc->sc_fbmem == NULL)
return (-1);
}
-
+ sc->sc_fbmemsize = size;
return (0);
}
@@ -1446,8 +1446,9 @@ void
udl_fbmem_free(struct udl_softc *sc)
{
if (sc->sc_fbmem != NULL) {
- free(sc->sc_fbmem, M_DEVBUF, 0);
+ free(sc->sc_fbmem, M_DEVBUF, sc->sc_fbmemsize);
sc->sc_fbmem = NULL;
+ sc->sc_fbmemsize = 0;
}
}
diff --git a/sys/dev/usb/udl.h b/sys/dev/usb/udl.h
index a969267e664..e62b83fc471 100644
--- a/sys/dev/usb/udl.h
+++ b/sys/dev/usb/udl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udl.h,v 1.21 2013/04/15 09:23:02 mglocker Exp $ */
+/* $OpenBSD: udl.h,v 1.22 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
@@ -75,6 +75,7 @@ struct udl_softc {
uint8_t sc_depth;
uint8_t sc_cursor_on;
uint8_t *sc_fbmem; /* framebuffer for X11 */
+ size_t sc_fbmemsize;
uint16_t sc_chip;
#define DLALL 0x0000
#define DL125 0x0000 /* max 1280x1024, 1440x900 */
diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c
index 5e036463311..f23450b7126 100644
--- a/sys/dev/usb/ulpt.c
+++ b/sys/dev/usb/ulpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ulpt.c,v 1.53 2016/03/03 18:13:24 stefan Exp $ */
+/* $OpenBSD: ulpt.c,v 1.54 2017/03/26 15:31:15 deraadt Exp $ */
/* $NetBSD: ulpt.c,v 1.57 2003/01/05 10:19:42 scw Exp $ */
/* $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $ */
@@ -713,7 +713,7 @@ close_pipe:
usbd_close_pipe(sc->sc_out_pipe);
sc->sc_out_pipe = NULL;
free_ucode:
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
return (error);
}
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index d3165bc8157..ae330debbff 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.131 2016/09/19 16:46:10 mpi Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.132 2017/03/26 15:31:15 deraadt Exp $ */
/* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -1398,7 +1398,7 @@ usbd_get_cdesc(struct usbd_device *dev, int index, u_int *lenp)
cdesc = malloc(len, M_TEMP, M_WAITOK);
err = usbd_get_desc(dev, UDESC_CONFIG, index, len, cdesc);
if (err) {
- free(cdesc, M_TEMP, 0);
+ free(cdesc, M_TEMP, len);
return (0);
}
}
@@ -1435,7 +1435,7 @@ usb_free_device(struct usbd_device *dev)
if (dev->serial != NULL)
free(dev->serial, M_USB, USB_MAX_STRING_LEN);
- free(dev, M_USB, 0);
+ free(dev, M_USB, sizeof *dev);
}
/*
diff --git a/sys/dev/usb/uticom.c b/sys/dev/usb/uticom.c
index 5ee6d2f1844..b82636bbd3a 100644
--- a/sys/dev/usb/uticom.c
+++ b/sys/dev/usb/uticom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uticom.c,v 1.30 2016/05/24 05:35:01 mpi Exp $ */
+/* $OpenBSD: uticom.c,v 1.31 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2005 Dmitry Komissaroff <dxi@mail.ru>.
*
@@ -863,7 +863,7 @@ uticom_download_fw(struct uticom_softc *sc, int pipeno,
if (!buffer) {
printf("%s: uticom_download_fw: out of memory\n",
sc->sc_dev.dv_xname);
- free(firmware, M_DEVBUF, 0);
+ free(firmware, M_DEVBUF, firmware_size);
return ENOMEM;
}
@@ -913,12 +913,12 @@ uticom_download_fw(struct uticom_softc *sc, int pipeno,
sc->sc_dev.dv_xname, usbd_errstr(err));
finish:
- free(firmware, M_DEVBUF, 0);
+ free(firmware, M_DEVBUF, firmware_size);
usbd_free_buffer(oxfer);
usbd_free_xfer(oxfer);
oxfer = NULL;
usbd_abort_pipe(pipe);
usbd_close_pipe(pipe);
- free(buffer, M_USBDEV, 0);
+ free(buffer, M_USBDEV, buffer_size);
return err;
}
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 83a48ae1100..2fa4c0a85cd 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.192 2016/06/17 07:59:16 mglocker Exp $ */
+/* $OpenBSD: uvideo.c,v 1.193 2017/03/26 15:31:15 deraadt Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -3647,7 +3647,7 @@ uvideo_ucode_loader_ricoh(struct uvideo_softc *sc)
while (remain > 0) {
if (remain < 3) {
printf("%s: ucode file incomplete!\n", DEVNAME(sc));
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
return (USBD_INVAL);
}
@@ -3661,7 +3661,7 @@ uvideo_ucode_loader_ricoh(struct uvideo_softc *sc)
if (error != USBD_NORMAL_COMPLETION) {
printf("%s: ucode upload error=%s!\n",
DEVNAME(sc), usbd_errstr(error));
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
return (USBD_INVAL);
}
DPRINTF(1, "%s: uploaded %d bytes ucode to addr 0x%x\n",
@@ -3670,7 +3670,7 @@ uvideo_ucode_loader_ricoh(struct uvideo_softc *sc)
offset += len;
remain -= len;
}
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
/* activate microcode */
cbuf = 0;
@@ -3726,7 +3726,7 @@ uvideo_ucode_loader_apple_isight(struct uvideo_softc *sc)
if (len < 1 || len > 1023) {
printf("%s: ucode header contains wrong value!\n",
DEVNAME(sc));
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
return (USBD_INVAL);
}
code += 4;
@@ -3743,14 +3743,14 @@ uvideo_ucode_loader_apple_isight(struct uvideo_softc *sc)
if (error) {
printf("%s: ucode load failed: %s\n",
DEVNAME(sc), usbd_errstr(error));
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
return (USBD_INVAL);
}
code += llen;
}
}
- free(ucode, M_DEVBUF, 0);
+ free(ucode, M_DEVBUF, ucode_size);
/* send finished request */
cbuf = 0;