Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Don't leak memory in previous
details: https://anonhg.NetBSD.org/src/rev/82fb4ed8dff3
branches: nick-nhusb
changeset: 334130:82fb4ed8dff3
user: skrll <skrll%NetBSD.org@localhost>
date: Thu Mar 05 08:48:07 2015 +0000
description:
Don't leak memory in previous
diffstat:
sys/dev/usb/usbdi.c | 15 ++++++++++-----
sys/dev/usb/usbdivar.h | 3 ++-
2 files changed, 12 insertions(+), 6 deletions(-)
diffs (88 lines):
diff -r 7f761bf9997f -r 82fb4ed8dff3 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Thu Mar 05 08:34:47 2015 +0000
+++ b/sys/dev/usb/usbdi.c Thu Mar 05 08:48:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.162.2.11 2015/03/05 08:34:47 skrll Exp $ */
+/* $NetBSD: usbdi.c,v 1.162.2.12 2015/03/05 08:48:07 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.11 2015/03/05 08:34:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.12 2015/03/05 08:48:07 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -231,6 +231,7 @@
usbd_setup_xfer(xfer, ipipe, priv, buffer, len, flags,
USBD_NO_TIMEOUT, cb);
ipipe->up_intrxfer = xfer;
+ ipipe->up_intrbuf = buf;
ipipe->up_repeat = 1;
err = usbd_transfer(xfer);
*pipe = ipipe;
@@ -274,8 +275,10 @@
pipe->up_endpoint->ue_refcnt--;
pipe->up_methods->upm_close(pipe);
usbd_unlock_pipe(pipe);
- if (pipe->up_intrxfer != NULL)
+ if (pipe->up_intrxfer != NULL) {
usbd_free_xfer(pipe->up_intrxfer);
+ usbd_free_buffer(pipe->up_intrbuf);
+ }
kmem_free(pipe, pipe->up_dev->ud_bus->ub_pipesize);
return USBD_NORMAL_COMPLETION;
}
@@ -1069,6 +1072,7 @@
{
usbd_xfer_handle xfer;
usbd_status err;
+ void *buf = NULL;
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
@@ -1079,14 +1083,13 @@
return USBD_NOMEM;
if (UGETW(req->wLength) != 0) {
- void *buf = usbd_alloc_buffer(xfer, UGETW(req->wLength));
+ buf = usbd_alloc_buffer(xfer, UGETW(req->wLength));
if (buf == NULL) {
err = ENOMEM;
goto bad;
}
}
-
usbd_setup_default_xfer(xfer, dev, 0, timeout, req,
data, UGETW(req->wLength), flags, 0);
xfer->ux_pipe = pipe;
@@ -1149,6 +1152,8 @@
usbd_errstr(err), 0, 0, 0);
}
usbd_free_xfer(xfer);
+ if (buf)
+ usbd_free_buffer(buf);
return err;
}
diff -r 7f761bf9997f -r 82fb4ed8dff3 sys/dev/usb/usbdivar.h
--- a/sys/dev/usb/usbdivar.h Thu Mar 05 08:34:47 2015 +0000
+++ b/sys/dev/usb/usbdivar.h Thu Mar 05 08:48:07 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.109.2.12 2015/03/05 08:34:47 skrll Exp $ */
+/* $NetBSD: usbdivar.h,v 1.109.2.13 2015/03/05 08:48:07 skrll Exp $ */
/*
* Copyright (c) 1998, 2012 The NetBSD Foundation, Inc.
@@ -225,6 +225,7 @@
struct usb_task up_async_task;
usbd_xfer_handle up_intrxfer; /* used for repeating requests */
+ void *up_intrbuf;
char up_repeat;
int up_interval;
uint8_t up_flags;
Home |
Main Index |
Thread Index |
Old Index