From owner-freebsd-current@freebsd.org Mon Jul 27 12:59:01 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC9A19AA5DE for ; Mon, 27 Jul 2015 12:59:01 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pa0-x22f.google.com (mail-pa0-x22f.google.com [IPv6:2607:f8b0:400e:c03::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AFC9387D; Mon, 27 Jul 2015 12:59:01 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by pachj5 with SMTP id hj5so51321699pac.3; Mon, 27 Jul 2015 05:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=TRzdqDAf2xRMK0PpyzJdXonTpOeOmwJEaibA0Uyky/k=; b=wuZoWYbngaShr8k1ZT6xmxZCXN1bonwBA/Iqwuy4e/QPBaySAwuSucYsWzKaxaTpQR lh93D0unygQao4nB+6JZV9jN+g/Fy0fbSNABXbG1MhHNKS2FbDvcqNpnUJ7TA7OxV5Ye Qq4fYq7KC6AVptiT5VT3TLnsYko48n5QuyZkNViOpLK2fTAO5fpYpsUD+JgvwNRvN7fl 1pCWjCX0PTy4uNN1M5Ri8kWaIZPWdcoq9EkWdjKupuDVfXerRhIuU17BBU2JcnGdT4H9 9q5EnLEd7Elcu3HWZl+wmBaj202NHt6SGRlJJOJsz6t0yfxxkn4Rbi2dvfiI8jaVi73f RV+w== X-Received: by 10.66.136.39 with SMTP id px7mr68272057pab.141.1438001939754; Mon, 27 Jul 2015 05:58:59 -0700 (PDT) Received: from pyunyh@gmail.com ([106.247.248.2]) by smtp.gmail.com with ESMTPSA id da3sm29495428pdb.8.2015.07.27.05.58.55 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 27 Jul 2015 05:58:58 -0700 (PDT) From: Yonghyeon PYUN X-Google-Original-From: "Yonghyeon PYUN" Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Mon, 27 Jul 2015 21:58:51 +0900 Date: Mon, 27 Jul 2015 21:58:51 +0900 To: Hans Petter Selasky Cc: FreeBSD Current , Sean Bruno Subject: Re: E1000 mbuf leaks Message-ID: <20150727125850.GA986@michelle.fasterthan.com> Reply-To: pyunyh@gmail.com References: <55B60FC8.2020003@selasky.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <55B60FC8.2020003@selasky.org> User-Agent: Mutt/1.4.2.3i X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jul 2015 12:59:02 -0000 On Mon, Jul 27, 2015 at 01:02:32PM +0200, Hans Petter Selasky wrote: > Hi, > > I'm currently doing some busdma work, and possibly stepped over some > driver bugs. When "bus_dmamap_load_mbuf_sg()" returns ENOMEM the mbuf > chain is not freed. Is there some magic in "bus_dmamap_load_mbuf_sg()" > for that error code or is there a possible memory leak in all E1000 > drivers? See attached patch. I don't think it's an mbuf leak since lem(4) just prepend the mbuf to the if sendq(driver will retry it later). But I think your patch looks more correct in bus_dma(9) perspective. If bus_dmamap_load_mbuf_sg(9) returned an error except EFBIG, it would be correct for lem(4) to free the mbuf chains rather than restarting the bus_dmamap_load_mbuf_sg(9) later which shall fail again with ENOMEM.