NetBSD Problem Report #41602

From www@NetBSD.org  Tue Jun 16 13:59:29 2009
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id DEC5D63B8BA
	for <gnats-bugs@gnats.netbsd.org>; Tue, 16 Jun 2009 13:59:28 +0000 (UTC)
Message-Id: <20090616135928.6086563B885@www.NetBSD.org>
Date: Tue, 16 Jun 2009 13:59:28 +0000 (UTC)
From: linzhenhua01172@gmail.com
Reply-To: linzhenhua01172@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [usb][ohci]In function open_pipe(), may cause memory leak.
X-Send-Pr-Version: www-1.0

>Number:         41602
>Category:       kern
>Synopsis:       [usb][ohci]In function open_pipe(), may cause memory leak.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 16 14:00:01 +0000 2009
>Closed-Date:    Sun Dec 23 17:03:45 +0000 2012
>Last-Modified:  Sat Jan 05 23:35:02 +0000 2013
>Originator:     zhenhua,lin
>Release:        no
>Organization:
h3c
>Environment:
In private system, with the USB stack implemented in NetBsd.
>Description:
In function open_pipe(), the following two cases in the switch statement "switch (xfertype)" may cause memory leak:
>>>>>>>>>>>>>>>>>>>>>>>>>>>
		case UE_INTERRUPT:
			pipe->methods = &ohci_device_intr_methods;
			ival = pipe->interval;
			if (ival == USBD_DEFAULT_INTERVAL)
				ival = ed->bInterval;
			return (ohci_device_setintr(sc, opipe, ival));
		case UE_ISOCHRONOUS:
			pipe->methods = &ohci_device_isoc_methods;
			return (ohci_setup_isoc(pipe));
<<<<<<<<<<<<<<<<<<<<<<<<<<<<

if the functions ohci_device_setintr() & ohci_setup_isoc() return !USBD_NORMAL_COMPLETION, then it will cause the memory which were used by "std, sed" not be free.
>How-To-Repeat:
review it.
>Fix:
just demo, not verify yet.
===========================
		case UE_INTERRUPT:
			pipe->methods = &ohci_device_intr_methods;
			ival = pipe->interval;
			if (ival == USBD_DEFAULT_INTERVAL)
				ival = ed->bInterval;
			return (ohci_device_setintr(sc, opipe, ival));
		case UE_ISOCHRONOUS:
			pipe->methods = &ohci_device_isoc_methods;
			return (ohci_setup_isoc(pipe));
		case UE_BULK:



----->

		case UE_INTERRUPT:
			pipe->methods = &ohci_device_intr_methods;
			ival = pipe->interval;
			if (ival == USBD_DEFAULT_INTERVAL)
				ival = ed->bInterval;
-			return (ohci_device_setintr(sc, opipe, ival));
+			err = ohci_device_setintr(sc, opipe, ival);
+                       if (err)
+                          goto bad;
+                       break;
		case UE_ISOCHRONOUS:
			pipe->methods = &ohci_device_isoc_methods;
-			return (ohci_setup_isoc(pipe));
+                       err = ohci_setup_isoc(pipe);
+                       if (err)
+                          goto bad;
+                       break;
		case UE_BULK:

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Tue, 16 Jun 2009 14:30:52 +0000
Responsible-Changed-Why:
I'll handle it


State-Changed-From-To: open->analyzed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Tue, 16 Jun 2009 14:30:52 +0000
State-Changed-Why:
looks correct


State-Changed-From-To: analyzed->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Sun, 23 Dec 2012 17:03:45 +0000
State-Changed-Why:
Fix applied.


From: "Nick Hudson" <skrll@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41602 CVS commit: src/sys/dev/usb
Date: Sun, 23 Dec 2012 17:00:13 +0000

 Module Name:	src
 Committed By:	skrll
 Date:		Sun Dec 23 17:00:13 UTC 2012

 Modified Files:
 	src/sys/dev/usb: ohci.c

 Log Message:
 PR/41602

 Fix a memory leak when ohci_device_setintr didn't return
 USBD_NORMAL_COMPLETION.

 ohci_setup_isoc always returns USBD_NORMAL_COMPLETION at the moment so
 there's no chance of a leak there.


 To generate a diff of this commit:
 cvs rdiff -u -r1.225 -r1.226 src/sys/dev/usb/ohci.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41602 CVS commit: [netbsd-6] src/sys/dev/usb
Date: Sat, 5 Jan 2013 23:30:05 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Sat Jan  5 23:30:05 UTC 2013

 Modified Files:
 	src/sys/dev/usb [netbsd-6]: ohci.c

 Log Message:
 Pull up following revision(s) (requested by skrll in ticket #765):
 	sys/dev/usb/ohci.c: revision 1.226
 PR/41602
 Fix a memory leak when ohci_device_setintr didn't return
 USBD_NORMAL_COMPLETION.
 ohci_setup_isoc always returns USBD_NORMAL_COMPLETION at the moment so
 there's no chance of a leak there.
 PR/41602
 Fix a memory leak when ohci_device_setintr didn't return
 USBD_NORMAL_COMPLETION.
 ohci_setup_isoc always returns USBD_NORMAL_COMPLETION at the moment so
 there's no chance of a leak there.


 To generate a diff of this commit:
 cvs rdiff -u -r1.218 -r1.218.8.1 src/sys/dev/usb/ohci.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.