Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Fix a memory leak. Spotted by nat@
details: https://anonhg.NetBSD.org/src/rev/9a3ef98afdc2
branches: trunk
changeset: 745017:9a3ef98afdc2
user: skrll <skrll%NetBSD.org@localhost>
date: Fri Feb 21 12:41:29 2020 +0000
description:
Fix a memory leak. Spotted by nat@
diffstat:
sys/arch/mips/adm5120/dev/ahci.c | 7 +++++--
sys/dev/usb/ehci.c | 8 +++++---
sys/dev/usb/ohci.c | 6 ++++--
sys/dev/usb/uhci.c | 5 +++--
sys/external/bsd/dwc2/dwc2.c | 8 ++++++--
5 files changed, 23 insertions(+), 11 deletions(-)
diffs (149 lines):
diff -r 80dc66e94253 -r 9a3ef98afdc2 sys/arch/mips/adm5120/dev/ahci.c
--- a/sys/arch/mips/adm5120/dev/ahci.c Fri Feb 21 02:04:40 2020 +0000
+++ b/sys/arch/mips/adm5120/dev/ahci.c Fri Feb 21 12:41:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahci.c,v 1.20 2020/02/15 01:21:56 riastradh Exp $ */
+/* $NetBSD: ahci.c,v 1.21 2020/02/21 12:41:29 skrll Exp $ */
/*-
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.20 2020/02/15 01:21:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.21 2020/02/21 12:41:29 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -989,6 +989,9 @@
usb_transfer_complete(xfer);
mutex_exit(&sc->sc_lock);
+
+ usb_freemem(&sc->sc_bus, &reqdma);
+
return USBD_NORMAL_COMPLETION;
}
diff -r 80dc66e94253 -r 9a3ef98afdc2 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c Fri Feb 21 02:04:40 2020 +0000
+++ b/sys/dev/usb/ehci.c Fri Feb 21 12:41:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.273 2020/02/15 01:21:56 riastradh Exp $ */
+/* $NetBSD: ehci.c,v 1.274 2020/02/21 12:41:29 skrll Exp $ */
/*
* Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.273 2020/02/15 01:21:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.274 2020/02/21 12:41:29 skrll Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -3748,7 +3748,7 @@
ehci_device_ctrl_close(struct usbd_pipe *pipe)
{
ehci_softc_t *sc = EHCI_PIPE2SC(pipe);
- /*struct ehci_pipe *epipe = EHCI_PIPE2EPIPE(pipe);*/
+ struct ehci_pipe * const epipe = EHCI_PIPE2EPIPE(pipe);
EHCIHIST_FUNC(); EHCIHIST_CALLED();
@@ -3757,6 +3757,8 @@
DPRINTF("pipe=%#jx", (uintptr_t)pipe, 0, 0, 0);
ehci_close_pipe(pipe, sc->sc_async_head);
+
+ usb_freemem(&sc->sc_bus, &epipe->ctrl.reqdma);
}
/*
diff -r 80dc66e94253 -r 9a3ef98afdc2 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Fri Feb 21 02:04:40 2020 +0000
+++ b/sys/dev/usb/ohci.c Fri Feb 21 12:41:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.295 2020/02/15 01:21:56 riastradh Exp $ */
+/* $NetBSD: ohci.c,v 1.296 2020/02/21 12:41:29 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.295 2020/02/15 01:21:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.296 2020/02/21 12:41:29 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2841,6 +2841,8 @@
DPRINTF("pipe=%#jx", (uintptr_t)pipe, 0, 0, 0);
ohci_close_pipe(pipe, sc->sc_ctrl_head);
ohci_free_std_locked(sc, opipe->tail.td);
+
+ usb_freemem(&sc->sc_bus, &opipe->ctrl.reqdma);
}
/************************/
diff -r 80dc66e94253 -r 9a3ef98afdc2 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c Fri Feb 21 02:04:40 2020 +0000
+++ b/sys/dev/usb/uhci.c Fri Feb 21 12:41:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.293 2020/02/15 01:21:56 riastradh Exp $ */
+/* $NetBSD: uhci.c,v 1.294 2020/02/21 12:41:29 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.293 2020/02/15 01:21:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.294 2020/02/21 12:41:29 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -2807,6 +2807,7 @@
uhci_free_std_locked(sc, upipe->ctrl.setup);
uhci_free_std_locked(sc, upipe->ctrl.stat);
+ usb_freemem(&sc->sc_bus, &upipe->ctrl.reqdma);
}
/* Abort a device interrupt request. */
diff -r 80dc66e94253 -r 9a3ef98afdc2 sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c Fri Feb 21 02:04:40 2020 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c Fri Feb 21 12:41:29 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2.c,v 1.71 2020/02/15 14:05:06 riastradh Exp $ */
+/* $NetBSD: dwc2.c,v 1.72 2020/02/21 12:41:29 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.71 2020/02/15 14:05:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.72 2020/02/21 12:41:29 skrll Exp $");
#include "opt_usb.h"
@@ -764,9 +764,13 @@
Static void
dwc2_device_ctrl_close(struct usbd_pipe *pipe)
{
+ struct dwc2_softc * const sc = DWC2_PIPE2SC(pipe);
+ struct dwc2_pipe * const dpipe = DWC2_PIPE2DPIPE(pipe);
DPRINTF("pipe=%p\n", pipe);
dwc2_close_pipe(pipe);
+
+ usb_freemem(&sc->sc_bus, &dpipe->req_dma);
}
Static void
Home |
Main Index |
Thread Index |
Old Index