aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/libusb20.c
diff options
context:
space:
mode:
authorAndrew Thompson <thompsa@FreeBSD.org>2009-11-08 20:03:52 +0000
committerAndrew Thompson <thompsa@FreeBSD.org>2009-11-08 20:03:52 +0000
commitccef4ddf40fee777575fe227405159a2b6d11dee (patch)
tree977c6deb1e9004ec847ecd42fbc6b89e7dc790cc /lib/libusb/libusb20.c
parentf5a034f95a3eb1e4c66310499d671929d89b3b43 (diff)
downloadsrc-ccef4ddf40fee777575fe227405159a2b6d11dee.tar.gz
src-ccef4ddf40fee777575fe227405159a2b6d11dee.zip
- fix refcounting error during data transfer
- fix a memory leak on the USB backend - fix invalid pointer computations (in one case memory outside the allocated area was written in LibUSB v1.0) - make sure memory is always initialised, also in failing cases - add missing functions from v1.0.4 PR: usb/140325 Reported by: Robert Jenssen Submitted by: Hans Petter Selasky MFC After: 3 days
Notes
Notes: svn path=/head/; revision=199055
Diffstat (limited to 'lib/libusb/libusb20.c')
-rw-r--r--lib/libusb/libusb20.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index 6e0ec476f3d3..1a338052c939 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -630,6 +630,9 @@ libusb20_dev_req_string_sync(struct libusb20_device *pdev,
struct LIBUSB20_CONTROL_SETUP_DECODED req;
int error;
+ /* make sure memory is initialised */
+ memset(ptr, 0, len);
+
if (len < 4) {
/* invalid length */
return (LIBUSB20_ERROR_INVALID_PARAM);
@@ -1093,7 +1096,8 @@ libusb20_be_free(struct libusb20_backend *pbe)
if (pbe->methods->exit_backend) {
pbe->methods->exit_backend(pbe);
}
- return;
+ /* free backend */
+ free(pbe);
}
void
@@ -1101,7 +1105,6 @@ libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device
{
pdev->beMethods = pbe->methods; /* copy backend methods */
TAILQ_INSERT_TAIL(&(pbe->usb_devs), pdev, dev_entry);
- return;
}
void
@@ -1109,5 +1112,4 @@ libusb20_be_dequeue_device(struct libusb20_backend *pbe,
struct libusb20_device *pdev)
{
TAILQ_REMOVE(&(pbe->usb_devs), pdev, dev_entry);
- return;
}