From owner-svn-src-all@freebsd.org Sun Oct 11 20:59:03 2015 Return-Path: Delivered-To: svn-src-all@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 857E0A11DC0; Sun, 11 Oct 2015 20:59:03 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4D5EF12F7; Sun, 11 Oct 2015 20:59:03 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9BKx2Vp086990; Sun, 11 Oct 2015 20:59:02 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9BKx2Z1086989; Sun, 11 Oct 2015 20:59:02 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201510112059.t9BKx2Z1086989@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sun, 11 Oct 2015 20:59:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289154 - head/sys/dev/ntb/if_ntb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Oct 2015 20:59:03 -0000 Author: cem Date: Sun Oct 11 20:59:02 2015 New Revision: 289154 URL: https://svnweb.freebsd.org/changeset/base/289154 Log: NTB: MFV b77b2637: Link toggle memory leak Each link-up will allocate a new NTB receive buffer when the NTB properties are negotiated with the remote system. These allocations did not check for existing buffers and thus did not free them. Now, the driver will check for an existing buffer and free it if not of the correct size, before trying to alloc a new one. Authored by: Jon Mason Obtained from: Linux Sponsored by: EMC / Isilon Storage Division Modified: head/sys/dev/ntb/if_ntb/if_ntb.c Modified: head/sys/dev/ntb/if_ntb/if_ntb.c ============================================================================== --- head/sys/dev/ntb/if_ntb/if_ntb.c Sun Oct 11 20:58:00 2015 (r289153) +++ head/sys/dev/ntb/if_ntb/if_ntb.c Sun Oct 11 20:59:02 2015 (r289154) @@ -1129,12 +1129,20 @@ ntb_set_mw(struct ntb_netdev *nt, int nu { struct ntb_transport_mw *mw = &nt->mw[num_mw]; + /* No need to re-setup */ + if (mw->size == size) + return (0); + + if (mw->size != 0) + ntb_free_mw(nt, num_mw); + /* Alloc memory for receiving data. Must be 4k aligned */ mw->size = size; mw->virt_addr = contigmalloc(mw->size, M_NTB_IF, M_ZERO, 0, BUS_SPACE_MAXADDR, mw->size, 0); if (mw->virt_addr == NULL) { + mw->size = 0; printf("ntb: Unable to allocate MW buffer of size %d\n", (int)mw->size); return (ENOMEM);