From owner-freebsd-current@FreeBSD.ORG Sun Jul 27 18:06:45 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BF0D637B401 for ; Sun, 27 Jul 2003 18:06:45 -0700 (PDT) Received: from mail.cyberonic.com (mail.cyberonic.com [4.17.179.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA96F43F85 for ; Sun, 27 Jul 2003 18:06:44 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (node-40244c0a.sfo.onnet.us.uu.net [64.36.76.10]) by mail.cyberonic.com (8.12.8/8.12.5) with ESMTP id h6S1cE0n027317; Sun, 27 Jul 2003 21:38:14 -0400 Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.9/8.11.6) id h6S16gkS086830; Sun, 27 Jul 2003 18:06:42 -0700 (PDT) (envelope-from jmg) Date: Sun, 27 Jul 2003 18:06:41 -0700 From: John-Mark Gurney To: Lukas Ertl Message-ID: <20030728010641.GQ10708@funkthat.com> Mail-Followup-To: Lukas Ertl , Gary Jennejohn , freebsd-current@freebsd.org, Mark Blackman References: <20030727163914.S698@korben.in.tern> <20030727191758.GN10708@funkthat.com> <20030728010746.I587@korben.in.tern> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="E/DnYTRukya0zdZ1" Content-Disposition: inline In-Reply-To: <20030728010746.I587@korben.in.tern> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: Gary Jennejohn cc: Mark Blackman cc: freebsd-current@freebsd.org Subject: Re: device driver memory leak in 5.1-20030726? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 01:06:46 -0000 --E/DnYTRukya0zdZ1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Lukas Ertl wrote this message on Mon, Jul 28, 2003 at 01:11 +0200: > Then I have no explanation. I'm running the box with a WiFi card, > generating lots of network traffic, and the box is running fine, no > panics, and low devbuf allocation. I'm running the box with the USB > Bluetooth dongle, generating much less traffic (it's just a 9.6kbit GSM > link), and the box panics within half an hour in kmem_malloc, with devbuf > allocation up to 74MB. It must be either in the Bluetooth code or in the > USB code. Upon futher looking at the code, I have a better fix for this. Let me know how things go for you. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --E/DnYTRukya0zdZ1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ng_device.diff" Index: ng_device.c =================================================================== RCS file: /home/ncvs/src/sys/netgraph/ng_device.c,v retrieving revision 1.3 diff -u -u -r1.3 ng_device.c --- ng_device.c 3 Mar 2003 12:15:52 -0000 1.3 +++ ng_device.c 28 Jul 2003 01:04:31 -0000 @@ -354,27 +354,13 @@ NGI_GET_M(item, m); NG_FREE_ITEM(item); - m = m_pullup(m,m->m_len); - if(m == NULL) { - printf("%s(): ERROR: m_pullup failed\n",__func__); - return(-1); - } - - buffer = malloc(sizeof(char)*m->m_len, M_DEVBUF, M_NOWAIT | M_ZERO); - if(buffer == NULL) { - printf("%s(): ERROR: buffer malloc failed\n",__func__); - return(-1); - } - - buffer = mtod(m,char *); - - if( (connection->loc+m->m_len) < NGD_QUEUE_SIZE) { - memcpy(connection->readq+connection->loc, buffer, m->m_len); - connection->loc += m->m_len; - } else + if( (connection->loc+m->m_len) < NGD_QUEUE_SIZE) + m_copydata(m, 0, m->m_len, connection->readq+connection->loc); + else + /* XXX - we really should handle this failure case better */ printf("%s(): queue full, first read out a bit\n",__func__); - free(buffer,M_DEVBUF); + m_freem(m); return(0); } --E/DnYTRukya0zdZ1--